I am working on USB device drivers where device gets detected as HID. I'm facing problem in compiler settings for address offset in case of HID and integrating my code with bootloader. I managed to find some leads on how how to do address offsetting in Atmel Studio 6.2. After spending some time on blogs and going through comments somehow I have got it working. I don't know though if this is the right way to do so. All I have done is
- Project -> Project Properties ->Tool Check the 'Override Vector Table Offset Register' and edit that field to '&exception_table'
- In Project -> Project Properties ->Toolchain -> ARM/GNU Linker -> Memory Settings I have added .text=0x00004100 In 'FLASH segment'. After making these changes, I was able to do address offsetting and code works fine. I checked .hex file too and verified it's starting from 0x00004100.
Bootloader code has reserved space 0x00000000 to 0x00004000.
So after programming the chip with bootloader code, device enters in CDC mode (COM Port) and allows you to load the firmware from there. I have c# utility to do so.
Hence after programming the chip with BL, I put lock on those memory locations by setting up fuse in Atmel Studio->Tools->Device Programming->Fuses.
Then when I try to load the firmware, instead of going into application code (Where it should enter in HID mode), it just sits there as CDC device (COM Port). I don't know where exactly I'm going wrong.
I know that there's no problem in BL code because, I'm doing the same thing for my other project where code jumps from BL to Application code (Test & Measurement Instrument in this case) and everything is working good. Similarly, here should not be any issue with Application Code (in case of HID device) because without BL, my application code (HID) works properly.
Hence I'm sure that there are some compiler settings or Atmel Studio IDE settings must for Address Offsetting & BL compatibility I'm missing in case of this project.
The other working project (BL to TMI) which I mentioned above is set up in Eclipse IDE and selection of IDE is the only difference here. There are some IDE issues where HID, Eclipse IDE, WDT & BL can't go together that's why I set up this project in Atmel Studio instead of Eclipse.
Help in this matter is really appreciated. It's been long since I'm trying to figure out the solution of this issue. The code I'm using to jump from Bootloader to Application code is -
#define APP_START_ADDRESS ((uint32_t)0x00004100) #define APP_START_RESET_VEC_ADDRESS (APP_START_ADDRESS+(uint32_t)0x00000004) /* Pointer to the Application Section */ void (*application_code_entry)(void); /* Rebase the Stack Pointer */ __set_MSP(*(uint32_t *) APP_START_ADDRESS); /* Rebase the vector table base address */ SCB->VTOR = ((uint32_t) APP_START_ADDRESS & SCB_VTOR_TBLOFF_Msk); /* Load the Reset Handler address of the application */ application_code_entry = (void (*)(void))(unsigned *)(*(unsigned *)(APP_START_RESET_VEC_ADDRESS)); /* Jump to user Reset Handler in the application */ application_code_entry();
I have checked that there's no problem at all in jumping from BL to Application code (CDC to TMI) but it fails to work in CDC to HID case.