Linking bootloader and firmware

For C and ASSEMBLY users to post questions and code snippets for programming in C and ASSEMBLY. And for any other C or ASM course related questions.

Moderators: Benj, Mods

User avatar
Mantas
Posts: 221
Joined: Tue May 15, 2012 10:32 pm
Location: Klaipeda, Lithuania - North sea, UK
Has thanked: 68 times
Been thanked: 27 times
Contact:

Linking bootloader and firmware

Postby Mantas » Mon Sep 21, 2015 6:37 pm

Hello guys,

I have problem with my bootloader and firmware, so here it goes. I've written a bootloader code which downloads new encrypted firmware via RS-485 conected to USART1 using XMODEM-CRC protocol, and AES-EAX decryption and authentication algorithm, and with flash patritioning. So basically it all works well with bootloader, it downloads new firware (performs CRC checks while doing it), decrypts it, checks authenticity, verifies that the firmware is genuine and copies it from buffer partition to the main one and jumps to the starting address of the firmware. I compile and link my bootloader with it's exception vectors sitting at the begining of the flash which is remaped (mirrored) to start at 0x0. So far so good (all works well), and I can verify the written memory content manually, and all looks exactly like unencrypted application in the binary viewer. I link the application to start at address just after bootloader, 0x108000 (or 0x008000), download it and jump to this address, and then application should copy its exception vectors to RAM, perform a repam so that RAM would be mirrored at 0x0. But after the jump the application carries out a couple of instructions in dissassembly and goes into abort exception. And I can't understand why this is happening....when I compile and download the application normally it works well...how does ARM bootloader do this, and how is flowcode compiling the applications? is it necessary to include assembly startup file for the ARM chip in firmware application? I think low level initialization is not mandatory as the processor is up and running...what about Cstack? IRQ stack? do i need new initialization for them in firmware? or do I need just to compile the bare application without any initializations and startup files? Is it possible to change flowcode linking address for the applications? Or is it permanently hardwritten in the software to be 0x002000?

Thanks alot for any help, because I've been bussy with this application for a couple of months now and I know I'm very close to getting it work, but just need to make this final push :mrgreen:

Cheers,
Mantas
Science is my true religion.

User avatar
Mantas
Posts: 221
Joined: Tue May 15, 2012 10:32 pm
Location: Klaipeda, Lithuania - North sea, UK
Has thanked: 68 times
Been thanked: 27 times
Contact:

Re: Linking bootloader and firmware

Postby Mantas » Wed Sep 23, 2015 5:38 pm

I found out how to edit the linking address...but the other questions still remain...still waiting for a reply, and/or suggestions on bootloader/firmware starting codes and linking.

BR,
Mantas
Science is my true religion.