Sirs
I am needing help on how to mount uv4 simple project to start the development of my bootloader. My design is :
- LPC1768 - AT45DB041D-SU (Data Flash), on SSP - Tibbo EM202, as ethernet-serial converter
The initial questions are:
- How to configure the keil project to launch any application to run/debugger at address 0x6000 ? I tried to configure IROM1 = 0x2000, but doesnt work. (I've called the System_Init() as first line of main() routine)
So What do I need to do ?
This code is coming from a bootloader that jumps to a bootloader - the comments are slightly misleading (corrected now):
/* One major difference between an ARM7 device and a Cortex-M3 is the content of the vector table: when you jump to application in an ARM7, you can expect code inside the vector table, so you can jump to its beginning and know you are correct. The vector table of a Cortex-M3 needs to be dereferenced in order to retrieve the entry point to the application. */ __asm void jump_to_application(void) { ; program stack pointer of application LDR R0, =0x6000 LDR SP, [R0] ; extract entry point into application LDR R0, =0x6004 ; jump LDR PC, [R0] }
Hi all
I compiled a code on 0x0000 and I did a simple code as showed below
#include "type.h" #include "LPC17xx.H" #define USER_FLASH_START 0x00002000 void execute_user_code(void) { void (*user_code_entry)(void); SCB->VTOR = USER_FLASH_START; user_code_entry = (void (*)(void))((USER_FLASH_START)+1); user_code_entry(); } int main(void) { SystemInit(); execute_user_code(); // call while(1); }
After that I compiled another existing project using the following layout IROM1=0x2000 to 0x8000 IRAM1=0x10000000 to 0x8000
I am using a Cortex-M/R J-Link/J-Trace HW : V5.90 , SW : V4.28
and i setup the programming algorithm to LPC17xx IAP 512K Flash and I modify the address range to Start : 0x2000 Size : 0x7E000 that setup the range to : 0x2000-0x7FFFF
Look the tests that I done
Test 1 - Erase the 0x2000-0x8000 flash using flash Magic - Download the firmware using JTAG (Ok, its run).
Test 2 - Erase all chip memory - Download the firmware at 2000 using JTAG - Reset and nothing happened (Ok, of course) - DOwnload the my bootloader using flash magic at 0x000 - Reset (ok, the firmware at 2000 runs)
Test 3 (its my problem) - Erase the chip - Put the bootloader at 0x0000 - Download the desired app at 0x2000 - I uncheck the Run to main option and put a debug.ini file to $=0x2000 and g, main
When I start do debug, I can stop the application, after F5 command and nothing works (I put a breakpoint on routine before while(1)). After some seconds the Uvision crashes..
I am running the uvision under windows x64, with compatibility mode. It's not problem because if I debug any application at 0x0000 I can use debug normally.
When I download, the Keil put a message on output...
Load "C:\\Dados\\Firmware\\2011\\APPCA06\\release\\1_1\\source\\output\\APPCA06.AXF" Set JLink Project File to "C:\Dados\Firmware\2011\APPCA06\release\1_1\source\JLinkSettings.ini" JLink info: ------------ DLL: V4.28 , compiled Jun 16 2011 17:41:05 Firmware: J-Link compiled Jul 30 2008 11:24:37 ARM Rev.5 Hardware: V5.90 S/N : 28010838 Feature(s) : RDI, FlashDL, FlashBP, JFlash, GDBFull * JLink Info: TotalIRLen = 4, IRPrint = 0x01 * JLink Info: Found Cortex-M3 r2p0, Little endian. * JLink Info: TPIU fitted. * JLink Info: ETM fitted. * JLink Info: FPUnit: 6 code (BP) slots and 2 literal slots ROMTableAddr = 0xE00FF003 * JLink Info: TotalIRLen = 4, IRPrint = 0x01 * JLink Info: Found Cortex-M3 r2p0, Little endian. * JLink Info: TPIU fitted. * JLink Info: ETM fitted. * JLink Info: FPUnit: 6 code (BP) slots and 2 literal slots * JLink Info: TotalIRLen = 4, IRPrint = 0x01 * JLink Info: Found Cortex-M3 r2p0, Little endian. * JLink Info: TPIU fitted. * JLink Info: ETM fitted. * JLink Info: FPUnit: 6 code (BP) slots and 2 literal slots Target info: ------------ Device: LPC1768 VTarget = 3.235V State of Pins: TCK: 1, TDI: 0, TDO: 1, TMS: 0, TRES: 1, TRST: 1 Hardware-Breakpoints: 6 Software-Breakpoints: 8192 Watchpoints: 4 JTAG speed: 2000 kHz No Algorithm found for: 000002FCH - 000002FFH Partial Erase Done (areas with no algorithms skipped!) No Algorithm found for: 000002FCH - 000002FFH Partial Programming Done (areas with no algorithms skipped!) Partial Verify OK (areas with no algorithms skipped!) * JLink Info: TotalIRLen = 4, IRPrint = 0x01 * JLink Info: Found Cortex-M3 r2p0, Little endian. * JLink Info: TPIU fitted. * JLink Info: ETM fitted. * JLink Info: FPUnit: 6 code (BP) slots and 2 literal slots Application running ... ***JLink Error: Bad JTAG communication: Write to IR: Expected 0x1, got 0x0 (TAP Command : 10) @ Off 0x15D.
Observations My Application call SystemInit() on beginning. If I just download its run perfectly (with several interrupts active) 3 serials, ssp, rtc, I2c, mci and so on.
Why the app crashes on debug mode (just on 0x2000) ? Any help ?
PS: If possible I desire to chat with someone. Regards
Jean Fernandes System Engineer
If I understand you correctly, your application at 0x2000 only runs if activated from your boot loader. Not when you instead tries to get the debugger to directly start execution at 0x2000.
The question then - what startup code does the application have? And what startup code does the boot loader have?
A direct jump to 0x2000 from the debugger means that you haven't run the code from the startup file of the boot loader which might do something that your main application forgets to do. Who is remapping the interrupt vector table into RAM?
At 0x0000
<prev> #include "type.h" #include "LPC17xx.H"
#define USER_FLASH_START 0x00002000
void execute_user_code(void) { void (*user_code_entry)(void);
SCB->VTOR = USER_FLASH_START; user_code_entry = (void (*)(void))((USER_FLASH_START)+1); user_code_entry(); }
int main(void) {
SystemInit(); execute_user_code(); // call while(1); } </prev>
It's run perfectly. Note that each Keil project I have separated files to manipulate : lpc17xx.h, core_cm3.h, system_lpc17xx.c, startup_lpc17xx.s (I use folders named /common/src and /common/inc under the /source folder)
Yesterday, I change a system_lpc17xx.c of my application (that runs at 0x2000). I put at end of this file the following code <prev> // Set Vector table offset value #if (__RAM_MODE__==1) SCB->VTOR = 0x10000000 & 0x3FFFFF80; #else SCB->VTOR = USER_FLASH_ADDRESS & 0x3FFFFF80; // SCB->VTOR = 0x00000000 & 0x3FFFFF80; #endif </prev>
and
on Lpc17xx.h
<prev> #define USER_FLASH_ADDRESS 0x00002000 </prev>
After that debug runs ok, but there are a curious flash data written on <prev> 0x0000001C 0007 MOVS r7,r0 0x0000001E 0000 MOVS r0,r0 </prev> I've noted this on disassembly window. I am searching for the reason.
Any help ?
At 0x0000, i wrote a simple application
Yesterday, I change a system_lpc17xx.c of my application (that runs at 0x2000). I put at end of this file the following code
// Set Vector table offset value #if (__RAM_MODE__==1) // <--- i didn't discover the definition on project yet !!! SCB->VTOR = 0x10000000 & 0x3FFFFF80; #else SCB->VTOR = USER_FLASH_ADDRESS; // change the vector to desired address // SCB->VTOR = 0x00000000 & 0x3FFFFF80; #endif
#define USER_FLASH_ADDRESS 0x00002000
After that debug runs ok, but there are a curious flash data written on
0x0000001C 0007 MOVS r7,r0 0x0000001E 0000 MOVS r0,r0
I've noted this on disassembly window. I am searching for the reason.
Hi,
have you looked at the application note of NXP? It explains well how to make the bootloader with the LPC1768.
ics.nxp.com/.../an10866.zip
good luck.