| View previous topic :: View next topic |
| Author |
Message |
Rohit de Sa
Joined: 09 Nov 2007 Posts: 282 Location: India
|
|
Posted: Tue May 05, 2009 8:28 pm |
|
|
I know I may be digressing a bit, but if you are looking for a simple mass-storage based project this is an interesting link:
http://direction.scene-double.com/2008/07/08/usb-msd-bootloader-for-pic-microcontrollers.aspx
Essentially, it is a mass-storage based bootloader. The project is made for Microchip's C18, but I suppose it is an easy port to CCS.
To quote a few lines right from the designer's page:
The USB Bootloader is designed for Microchip PIC microcontrollers and has the following features:
- Emulates a USB Mass Storage Device (MSD) i.e. a flash drive
- Enables drag and drop firmware upgrades (using pre-formatted files) on any OS
- Facility to save/restore application data
Rohit |
|
 |
magestik
Joined: 16 Oct 2008 Posts: 59
|
|
Posted: Wed May 06, 2009 3:19 am |
|
|
I don't understand, according to the datasheet, the boot block is located from 0 to 7FFh.
So why the LOADER_SIZE here is FFFh ? that would make to boot block end @ FFFh instead of 7FFh.
| Code: | ///////////////////////////////////////////////////////////////////////////
//// USB_BOOTLOADER.H ////
//// ////
//// ////
///////////////////////////////////////////////////////////////////////////
//how big is the bootloader?
//the bootloader will reside from address 0x0000 to this location. the
//application will then sit at this location+1 to the end of program memory.
#define LOADER_SIZE (0xFFF)
#define LOADER_START (0)
#define LOADER_END (LOADER_SIZE)
#define APPLICATION_START (LOADER_SIZE+1)
#define APPLICATION_END (getenv("PROGRAM_MEMORY")-1)
#define APPLICATION_ISR (APPLICATION_START+8)
#ifndef _bootloader
//in the application, this moves the reset and isr vector out of the bootload
//space. it then reserves the loader space from being used by the application.
#build(reset=APPLICATION_START, interrupt=APPLICATION_ISR)
#org 0, LOADER_END {}
#endif |
|
|
 |
Rohit de Sa
Joined: 09 Nov 2007 Posts: 282 Location: India
|
|
Posted: Wed May 06, 2009 7:48 am |
|
|
As far as I am aware, the Vendor Class bootloader by Microchip (the one that uses PDFSUSB as the program on the host PC) occupies upto 0x7FF. The HID based bootloader, on the other hand requires upto 0xFFF.
Note: software and firmware for both bootloaders is available in v2.2 of Microchip's USB framework.
Rohit |
|
 |
mskala
Joined: 06 Mar 2007 Posts: 100 Location: Massachusetts, USA
|
|
Posted: Wed May 06, 2009 10:13 am |
|
|
| magestik wrote: | I didn't leave any detail, my schematic is the same as above, only running @3.3v with an additional voltage regulator.
There is a reason, the 18F4550 cannot operate @ 3.3v, which i need .
Could you post the bootloader you used for the 18LF4550 ?
Thanks. |
When USB is connected to my design, the LF4550 is running at 5V. I have hardware that isolates the rest of the 3.3V circuit and only powers the chip. This does not seem to apply for you.
Your code shows osc=20MHz. Use a value 16MHz or lower and change the code accordingly and see if it works. |
|
 |
magestik
Joined: 16 Oct 2008 Posts: 59
|
|
Posted: Mon May 11, 2009 2:22 am |
|
|
Hello, still fighting with the bootloader...
I tried the "USB Device - HID - HID Bootloader - C18 - PIC18F4550.hex" file, it worked, but now i guess i need to include the *.lkr file for the bootloader mapping, otherwise each time i send a *.hex file i will crush the boot section, but i don't know how to include this file.
Does someone know my next move ? .
Thank you.
@mskala : 20Mhz or 16Mhz, the program runs fine, without the bootloader.. :(
Last edited by magestik on Mon May 11, 2009 4:30 am; edited 2 times in total |
|
 |
magestik
Joined: 16 Oct 2008 Posts: 59
|
|
Posted: Mon May 11, 2009 4:24 am |
|
|
I think i managed to include the file "rm18f4550 - HID Bootload.lkr" to the project.
My project for now is just blinking a led.
The pic enters the boot mode each time i ask, but it won't run the program.
I'm guessing the boot section isn't crushed when i send a *.hex file, which mean the lkr file is correct for the boot location.
But when asking the program to run, nothing happens. maybe the start program location is incorrect ?
Here is the *.lkr file i included :
| Code: | // File: rm18f4550 - HID Bootload.lkr
// Use this linker for the USB application that will be self programmed by the HID bootloader.
// The HID bootloader project itself uses the BootModified.18f4550.lkr file instead.
// THIS LINKER SCRIPT HAS BEEN MODIFIED... This version is intended to be used
// with the "PROGRAMMABLE_WITH_USB_HID_BOOTLOADER" bootloader. The HID
// bootloader occupies memory ranges 0x000-0xFFF. In order for the code generated
// by this project to work with the bootloader, the linker must not put any code
// in the 0x00-0xFFF address range.
// This linker script was originated from the 18f4550.lkr file provided by
// the MCC18 distribution.
LIBPATH .
FILES c018i.o
FILES clib.lib
FILES p18f4550.lib
CODEPAGE NAME=bootloader START=0x0 END=0xFFF PROTECTED
CODEPAGE NAME=vectors START=0x1000 END=0x1029 PROTECTED
CODEPAGE NAME=page START=0x102A END=0x7FFF
CODEPAGE NAME=idlocs START=0x200000 END=0x200007 PROTECTED
CODEPAGE NAME=config START=0x300000 END=0x30000D PROTECTED
CODEPAGE NAME=devid START=0x3FFFFE END=0x3FFFFF PROTECTED
CODEPAGE NAME=eedata START=0xF00000 END=0xF000FF PROTECTED
ACCESSBANK NAME=accessram START=0x0 END=0x5F
DATABANK NAME=gpr0 START=0x60 END=0xFF
DATABANK NAME=gpr1 START=0x100 END=0x1FF
DATABANK NAME=gpr2 START=0x200 END=0x2FF
DATABANK NAME=gpr3 START=0x300 END=0x3FF
DATABANK NAME=usb4 START=0x400 END=0x4FF PROTECTED
DATABANK NAME=usb5 START=0x500 END=0x5FF PROTECTED
DATABANK NAME=usb6 START=0x600 END=0x6FF PROTECTED
DATABANK NAME=usb7 START=0x700 END=0x7FF PROTECTED
ACCESSBANK NAME=accesssfr START=0xF60 END=0xFFF PROTECTED
SECTION NAME=CONFIG ROM=config
STACK SIZE=0x100 RAM=gpr3
SECTION NAME=USB_VARS RAM=usb4 |
|
|
 |
PICoHolic
Joined: 04 Jan 2005 Posts: 224
|
|
Posted: Mon May 11, 2009 5:03 am |
|
|
magestik,
You don't need to modify the linker file .lkr
Just follow these steps:
1- Get the USB HID bootloader stuff from microchip website
2- Modify the bootloader for 18F4550 just to adapt to your hardware as i already stated in my previous reply. Compile it under C18.
3- Go back to CCS, include the usb_bootloader.h (posted above) to your project & compile.
4- Using ICD2 for ex, load the bootloader hex file compiled under C18 on chip
5- Using the PC HID bootloader, load your hex compiler under CCS... Make sure that RB4 is asserted correctly.
6- Enjoy |
|
 |
|