Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 9 months ago.
MBED code fails to run, when compiled in flash locations other than 0x0000000 (LPC1768 Bootloader)
Hello all,
I have been struggling with implementing an on chip secondary boot loader with the LPC1768 (custom board). However, the main issue is related to the mbed libraries.
Overview
I am compiling the bootloader code to start at flash sector 1 (0x0000000) I have compiled 2 bins, which I will refer to as "App code" to start at flash section 17 (0x00018000).
App Code 1 = Function is to blink the LED, using the mbed libraries. App Code 2 = Blink LED, but only using native NXP SDK
Boot Loader
The boot loader is written using mbed code, and it allows the user to select app code 1 or app code 2 for reading from a USB flash drive and then writing to flash section 17. After writing to flash using IAP, the code is executed.
Results are that the non-mbed based blink works flawlessly, but the mbed based blink will not execute. I suspect the issue is related to some mbed start up code or some other low level library modification made to accommodate mbed.
I would really appreciate help from anyone that may have gotten this to work. I think assistance from the MBED staff, would go along way here. This question has been asked many times on this forum, but never put to bed.
I have included code snippets below. Please help.
LPC1768.ld, uncomment based on whether I am compiling boot loader or app code
MEMORY { FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 96K /*Boot Loader*/ /*FLASH (rx) : ORIGIN = 0x00018000, LENGTH = (512K-96K)*/ /*app code*/ RAM (rwx) : ORIGIN = 0x100000C8, LENGTH = (32K - 0xC8) USB_RAM(rwx) : ORIGIN = 0x2007C000, LENGTH = 16K ETH_RAM(rwx) : ORIGIN = 0x20080000, LENGTH = 16K }
Please provide guidance on what else needs to be changed in the MBED startup (startup_LPC1768.s, system_LPC17xx.c, etc, etc) files to launch MBED code in another region other than sector 0.
1 Answer
10 years, 8 months ago.
Hi,
I think I'm experiencing the same problem: I'm trying to flash an application on a custom board using the USB secondary boot loader from codered. The application (based on the mbed libraries) fails to be launched successfully most of the time. It only works fine after initial power-up. When I reset the device the processor hangs just after the boot loader tries to load the user application.
Could you please detail a bit further on how to resolve the problem?
Thanks in advance, Lieven.
Problem solved, there were two problems:
- the vector table initialization indeed does not work correctly when using a secondary bootloader. I've created a pull request for this to the mbed lib github repo.
- the clock init settings in the mbed lib were conflicting with the clock init settings used by the boot loader (the regular CMSIS settings). Updating the settings in the mbed lib so that they are in line with those of the bootloader solved the problem.
Well unfortunately, no one has responded to this, was really hoping for some support from MBED staff.
I have made a further discovery. The process does work with MBED code, the issue is with the USBHOSTMSD. If I remove this code, it jumps into the MBED code flawlessly. However, if write USBHOSTMSD msd("usb"); anywhere in the boot loader or in the app code, the MBED app code crashes after jump. This happens EVEN IF I write that line in an un-referenced function..... Any ideas?
posted by Bright Idea 01 Apr 2014Ok - here we go again. There is definitely something that needs to be re-directed for mbed based libs to work outside of sector 0.
I found that even a simple wait will cause the app code to "lock up". Please see below:
Locks up when it hits mbed wait
@Simon Ford
posted by Bright Idea 01 Apr 2014(Continues to talk to myself) - I have resolved the issue with the code above. I found that sector 0 is "essentially" hard coded in NVIC_SetVector. I made code adjustments and the mbed code launches fine and the wait statement no longer locks. However, I am back to square one with the USBHostMSD library. It is still causing an issue if used in the boot loader. The main app code crashes when jumped to.
posted by Bright Idea 02 Apr 2014Ok - I have further narrowed down the issue to the RTOS implementation that the mbed USBHOST libs all use. I really wish they had kept the RTOS implementation separate from the core mbed libs.
Now I either need to find a way to fix the issue with RTOS or use another USB HOST Lib.. Still no response from MBED team.
posted by Bright Idea 02 Apr 2014Hi,
Could you please comment a bit more on the issue that you've narrowed down? A bit more details would help a lot.
Thanks, Bogdan
posted by Bogdan Marinescu 03 Apr 2014Hey Bogdan, after spending over 50 hours on this I finally got everything working. I am able to utilize USBHOSTMSD in the boot loader and main app. I am still disappointed that I have never heard back from the MBED team.
posted by Bright Idea 04 Apr 2014