Boot Loader Application On LPC1769:

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Boot Loader Application On LPC1769:

6,260 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Hareesha on Tue Feb 14 00:21:41 MST 2012
[COLOR=#000000][FONT=Times New Roman, serif][SIZE=4]Dear Friends,[/SIZE][/FONT][/COLOR]


[COLOR=#000000][FONT=Times New Roman, serif][SIZE=4]I am working on LPC 1769 Controller. I am trying to implement [B]boot loader[/B] in my application so that I can update the firmware in the target board MCU through network (I need to download the firmware to MCU without JTAG, through network).[/SIZE][/FONT][/COLOR]

[COLOR=#000000][FONT=Times New Roman, serif][SIZE=4]If anybody having standard code and suitable documents for this, Plz give me. [/SIZE][/FONT][/COLOR]

[COLOR=#000000][FONT=Times New Roman, serif][SIZE=4]And suggest me how to begin this application. [/SIZE][/FONT][/COLOR]

[SIZE=4]Thanks&Regards,[/SIZE]

[SIZE=4]Hareesha.[/SIZE]
0 Kudos
Reply
47 Replies

3,958 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by researchinnovation on Wed Apr 11 05:20:12 MST 2012
[SIZE=4][B][COLOR=Blue]Hi...!!!
I want to take/read file(.txt format doc format) continuously as an input for one of my application on I2C.
But when I use FILE *file and file =fopen("filename.txt","r"); it is   showing error and I tried few more things but it is showing error.
I have used #include "debug_printf.h" , #include "stdlib.h" and other required driver files, but still error is coming.

Please guide me on this or share any document available on c functions for LPCxpresso.

Thanks....:)[/COLOR][/B][/SIZE]
0 Kudos
Reply

3,958 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Hareesha on Thu Mar 15 23:17:50 MST 2012
[FONT=Verdana, sans-serif]Hi gbm and angle,[/FONT]

[FONT=Verdana, sans-serif]Shall I use [B]flash magic[/B] software in PC side to read .hex file and flash it into controller? Otherwise any other solutions are there? If yes plz suggest me.[/FONT]

[FONT=Verdana, sans-serif]I am connecting “PC USB” to “USB to RS485 converter” and taking TX & RX signals from that converter then this pc’s TX & RX signals are connecting to [SIZE=2]P0[2]/TXD0[/SIZE] [Pin NO.98]& [SIZE=2]P0[3]/RXD0 [/SIZE][Pin NO.99] respectively. For this connection I am receiving data in controller side through uart0. Shall I proceed this connection for downloading .hex file from PC.[/FONT]
0 Kudos
Reply

3,958 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Hareesha on Thu Mar 15 03:07:57 MST 2012
Hi gbm & Angelo,

Before also I gone through internet, But I think still I nedd to understand in depth.Okay as like ur suggestion, I will go in deep . . .
0 Kudos
Reply

3,958 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Polux rsv on Thu Mar 15 02:33:31 MST 2012
Google search with "bootloader lpc1768" as keywords give tons of links. Ok, lots of them are for questions, but you will also find links to already working application notes and examples.

Angelo
0 Kudos
Reply

3,958 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by gbm on Thu Mar 15 02:15:50 MST 2012
Have you ever heard of Internet search engines?
0 Kudos
Reply

3,958 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Hareesha on Thu Mar 15 01:38:50 MST 2012

Quote: Polux rsv
Judging from the question above, I must agree with GBM. You are missing some basic knoweledge about bootloader working principles: What are S19 or hex files, linker settings for the application in order to be downloaded and run properly by the boortloader, etc...

Angelo


------------------------------------
;););)

Okay Angelo,

I will also agree with you and gbm that I am week in some basics of bootloader concept, Plz can you suggest me any documents or links or anything to understood everything in depth of bootloader. I am googling for everything i needed, But I didnt get muchmore details in depth for bootloader concepts. I got more information in our this forum compare to googl.

Plz guide me also to get boot loader knowledge like you guys,
0 Kudos
Reply

3,958 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Polux rsv on Thu Mar 15 01:21:01 MST 2012

Quote: Hareesha

Here I am getting confuse, Shall I write .hex file data directly into flash OR is it necessary to convert into binary formate.



Judging from the question above, I must agree with GBM. You are missing some basic knoweledge about bootloader working principles: What are S19 or hex files, linker settings for the application in order to be downloaded and run properly by the boortloader, etc... 

Angelo
0 Kudos
Reply

3,958 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Hareesha on Wed Mar 14 23:03:36 MST 2012
Hi gbm,

Attched files contains datails about flash related modules. Plz once verify and let me know.
0 Kudos
Reply

3,958 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Hareesha on Wed Mar 14 21:53:07 MST 2012
Hi gbm,

Thanks for your reply,

I followed USB bootloder to use and understand flash write. I am writting required data form 16th sector,that is from 0x10000 (65536) location onwards.

if i execute [SIZE=2][COLOR=#7f0055][B]void[/B][/COLOR][FONT=Courier New, serif][COLOR=#000000] (*[/COLOR][/FONT][/SIZE][COLOR=#000000][FONT=Courier New, serif][SIZE=2]user_code_entry[/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2])([/SIZE][/FONT][/COLOR][COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]void[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2]); function, i will get reply as no source code is available from specified location,this shows that i linked to other location,[/SIZE][/FONT][/COLOR]

[B][SIZE=4][I]"You will need to read a .hex file record by record, convert it to binary and then program it."[/I][/SIZE][/B]

Here I am getting confuse, Shall I write .hex file data directly into flash OR is it necessary to convert into binary formate.

I didnt get [B]"FlashLED_64K"[/B] sample code. Plz can u tel me tht code path or if possible give me that code.(I think it is not simple LED Blinking code)

If you dont mind, before asking in forum, First I will study myself and if I wont understood then only I am asking in forum.
0 Kudos
Reply

3,958 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by gbm on Wed Mar 14 04:17:12 MST 2012
You need to learn a lot before you will be able to write your bootloader. Look at the FlashLED_64K example and some other bootloader examples.

Your bootloader will start at address 0 and it will occupy some Flash blocks. Your loaded firmware will need to go to some higher address - 0x10000 seems to be a good candidate. It must be linked to execute from this address.
You will need to read a .hex file record by record, convert it to binary and then program it.

Judging from the questions you ask, you won't be able to achieve the goal in less than 3 weeks (assuming you will actively investigate the topic, not only keep asking us basic questions without any self-study).
0 Kudos
Reply

3,958 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Hareesha on Wed Mar 14 01:00:49 MST 2012
Hi Zero,gbm,Angelo and all

does LINKER settings are requred for this???

Now I am writting some data into flash by direct add coding to "[B][COLOR=#808080]src"[/COLOR][/B] in using following function
[B][COLOR=#808080]unsigned write_flash(unsigned * dst, char * src, unsigned no_of_bytes).[/COLOR][/B]
[B][COLOR=#808080]So is it correct???[/COLOR][/B]
[FONT=Verdana][COLOR=#808080][FONT=Verdana][COLOR=#808080]So How can I check whether written data is correct or not???[/COLOR][/FONT]
[/COLOR][/FONT]
0 Kudos
Reply

3,958 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Hareesha on Tue Mar 13 21:03:14 MST 2012
[FONT=Verdana, serif]Hey I am getting confusion here, Plz help me,[/FONT]
[FONT=Verdana, serif]After receive data which of the following function can I use to write into flash,[/FONT]

[COLOR=#943634][FONT=Verdana, serif][COLOR=#000000][B]unsigned write_flash(unsigned * dst, char * src, unsigned no_of_bytes)
[/B][/COLOR][/FONT][/COLOR][COLOR=#943634][FONT=Verdana, serif][/FONT][/COLOR]
[FONT=Verdana, serif][B]OR[/B][/FONT]
[B][FONT=Verdana][/FONT][/B]
[COLOR=#943634][FONT=Verdana, serif][B]int[/B][/FONT][/COLOR][COLOR=#943634][FONT=Verdana, serif][B]BlockDevWrite[/B][/FONT][/COLOR][COLOR=#943634][FONT=Verdana, serif](U32 dwAddress, U8 * pbBuf);[/FONT][/COLOR]

[FONT=Verdana, serif]Both the functions are calling following function.[/FONT]
[COLOR=#943634][FONT=Verdana, serif][B]void[/B][/FONT][/COLOR][COLOR=#943634][FONT=Verdana, serif][B]write_data[/B][/FONT][/COLOR][COLOR=#943634][FONT=Verdana, serif]([/FONT][/COLOR][COLOR=#943634][FONT=Verdana, serif][B]unsigned[/B][/FONT][/COLOR][COLOR=#943634][FONT=Verdana, serif] cclk,[/FONT][/COLOR][COLOR=#943634][FONT=Verdana, serif][B]unsigned[/B][/FONT][/COLOR][COLOR=#943634][FONT=Verdana, serif] flash_address,[/FONT][/COLOR][COLOR=#943634][FONT=Verdana, serif][B]unsigned[/B][/FONT][/COLOR][COLOR=#943634][FONT=Verdana, serif] * flash_data_buf, [/FONT][/COLOR][COLOR=#943634][FONT=Verdana, serif][B]unsigned[/B][/FONT][/COLOR][COLOR=#943634][FONT=Verdana, serif] count);[/FONT][/COLOR]
0 Kudos
Reply

3,958 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Hareesha on Tue Mar 13 02:06:10 MST 2012
Otherwise, In short,

How to write received data into flash memory???

I tried in different way by looking example code for flash write. But not writting correctly.
And if i execute " [B]void [FONT=Courier New, serif][SIZE=3]execute_user_code[/SIZE][/FONT][FONT=Courier New, serif][SIZE=3]([/SIZE][/FONT][FONT=Courier New, serif][SIZE=3]void[/SIZE][/FONT][/B][FONT=Courier New, serif][SIZE=3][B])" function[/B] then I am getting error as user code is not available in specified location, This shows that I am not writting. [/SIZE][/FONT]
0 Kudos
Reply

3,958 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Hareesha on Tue Mar 13 00:39:11 MST 2012
[COLOR=#000000][FONT=Verdana, serif]Hi Friends, I am here once again after long time.[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana, serif]Now I am able to read ASCII value in controller side by using UART0 through serial communication. Received buffer having data as follows[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana, serif]UART0Buffer[ ] = {:100000000080001029010000F5000000F70000004A…………………..}[/FONT][/COLOR]

[COLOR=#000000][COLOR=#00b050][FONT=Courier New, serif][SIZE=4][B]If my approach is wrong and if anybody knows better approach plz let me know. That is what to do after receives the data???.[/B][/SIZE][/FONT][/COLOR][/COLOR]

[COLOR=#000000][FONT=Courier New, serif][SIZE=2]For testing purpose I am doing as follow approaches.[/SIZE][/FONT][/COLOR]

[COLOR=#000000][COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]unsigned[/B][/SIZE][/FONT][/COLOR][COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]int[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2] UART0Buffer[2] = {0x001F,0x001E,0x001D,0x001C,0x001B,0x001A };[/SIZE][/FONT][/COLOR][/COLOR]
[COLOR=#000000][COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]int[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2] no_of_bytes = 512;[/SIZE][/FONT][/COLOR][/COLOR]
[COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]while[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2](!CMD_SUCCESS)[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]{[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]write_flash(([/SIZE][/FONT][/COLOR][COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]unsigned[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2] *)sector_start_map[2],([/SIZE][/FONT][/COLOR][COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]char[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2] *)UART0Buffer,no_of_bytes);[/SIZE][/FONT][/COLOR]
[COLOR=#000000][COLOR=#000000][FONT=Courier New, serif][SIZE=2]}[/SIZE][/FONT][/COLOR][/COLOR]
[COLOR=#000000][COLOR=#ff0000][FONT=Courier New, serif][SIZE=3][B]BUT I am not able to write data into flash.[/B][/SIZE][/FONT][/COLOR][/COLOR]

[COLOR=#000000][FONT=Verdana, serif]And is there any wrong in approach and is it necessary to write block wise.[/FONT][/COLOR]

[COLOR=#000000][COLOR=#000000][FONT=Courier New, serif][SIZE=2]Standard flash write function is as follow [/SIZE][/FONT][/COLOR][/COLOR]
[COLOR=#000000][COLOR=#000000][FONT=Courier New, serif][SIZE=2]------[/SIZE][/FONT][/COLOR][/COLOR]
[COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]unsigned[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2][B]write_flash[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2]([/SIZE][/FONT][/COLOR][COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]unsigned[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2] * dst, [/SIZE][/FONT][/COLOR][COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]char[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2] * src, [/SIZE][/FONT][/COLOR][COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]unsigned[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2] no_of_bytes)[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]{[/SIZE][/FONT][/COLOR]
[COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]unsigned[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2] i;[/SIZE][/FONT][/COLOR]


[COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]if[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2] (flash_address == 0)[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]{[/SIZE][/FONT][/COLOR]
[COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]/* Store flash start address */[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]flash_address = ([/SIZE][/FONT][/COLOR][COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]unsigned[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2] *)dst;[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]}[/SIZE][/FONT][/COLOR]
[COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]for[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2]( i = 0;i<no_of_bytes;i++ )[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]{[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]flash_buf[(byte_ctr+i)] = *(src+i);[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]}[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]byte_ctr = byte_ctr + no_of_bytes;[/SIZE][/FONT][/COLOR]

[COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]if[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2]( byte_ctr == FLASH_BUF_SIZE)[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]{[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]find_erase_prepare_sector(SystemCoreClock/1000, ([/SIZE][/FONT][/COLOR][COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]unsigned[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2])flash_address);[/SIZE][/FONT][/COLOR]
[COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]if[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2](result_table[0] != CMD_SUCCESS)[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]{[/SIZE][/FONT][/COLOR]
[COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]while[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2](1);[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]}[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]write_data[/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2](SystemCoreClock/1000,([/SIZE][/FONT][/COLOR][COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]unsigned[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2])flash_address,([/SIZE][/FONT][/COLOR][COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]unsigned[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2] *)flash_buf,FLASH_BUF_SIZE);[/SIZE][/FONT][/COLOR]
[COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]if[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2](result_table[0] != CMD_SUCCESS)[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]{[/SIZE][/FONT][/COLOR]
[COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]while[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2](1); [/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2]}[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]byte_ctr = 0;[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]flash_address = 0;[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]}[/SIZE][/FONT][/COLOR]
[COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]return[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2](CMD_SUCCESS);[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]}[/SIZE][/FONT][/COLOR]

[COLOR=#000000][COLOR=#000000][FONT=Courier New, serif][SIZE=2]-----------[/SIZE][/FONT][/COLOR][/COLOR]

[COLOR=#000000][COLOR=#000000][FONT=Courier New, serif][SIZE=2]Otherwise shall I follow directly as follow,[/SIZE][/FONT][/COLOR][/COLOR]
[COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]unsigned[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2] * flash_address = 0;[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]flash_address = 0x2000;[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]# define FLASH_BUF_SIZE = 512;[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]write_data(SystemCoreClock/1000,([/SIZE][/FONT][/COLOR][COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]unsigned[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2])flash_address,([/SIZE][/FONT][/COLOR][COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]unsigned[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2] *)UART0Buffer,FLASH_BUF_SIZE);[/SIZE][/FONT][/COLOR]


[COLOR=#000000][COLOR=#000000][FONT=Courier New, serif][SIZE=2]--------[/SIZE][/FONT][/COLOR][/COLOR]
0 Kudos
Reply

3,958 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Hareesha on Thu Mar 01 21:48:12 MST 2012
[COLOR=#000000][FONT=Verdana, serif]Hi All,[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana, serif]I solved that error also. I created everything in new workspace and build then it is okay. And after build I am getting .hex file also. Now my work is to integrate all modules.[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana, serif]I am getting confusion about following function. Whether this function will execute previous existing code form 2[/FONT][FONT=Verdana, serif]nd[/FONT][FONT=Verdana, serif] sector or it will execute for required present code (to download required code in boot mode)???[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana, serif]That standard function is:[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana, serif]---------------------------------------------------------------------------------------------[/FONT][/COLOR]


[FONT=Courier New, serif][SIZE=3][B]void[/B][/SIZE][/FONT][FONT=Courier New, serif][SIZE=3][B]execute_user_code[/B][/SIZE][/FONT][FONT=Courier New, serif][SIZE=3][B]([/B][/SIZE][/FONT][FONT=Courier New, serif][SIZE=3][B]void[/B][/SIZE][/FONT][FONT=Courier New, serif][SIZE=3][B])[/B][/SIZE][/FONT]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]{[/SIZE][/FONT][/COLOR]
[COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]void[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2] (*[/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2]user_code_entry[/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2])([/SIZE][/FONT][/COLOR][COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]void[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2]);[/SIZE][/FONT][/COLOR]


[COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]unsigned[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2] *p; [/SIZE][/FONT][/COLOR][COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]// used for loading address of reset handler from user flash[/SIZE][/FONT][/COLOR]


[COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]/* Change the Vector Table to the USER_FLASH_START[/SIZE][/FONT][/COLOR]
[COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]in case the user application uses interrupts */[/SIZE][/FONT][/COLOR]


[COLOR=#000000][FONT=Courier New, serif][SIZE=2]SCB->[/SIZE][/FONT][/COLOR][COLOR=#0000c0][FONT=Courier New, serif][SIZE=2]VTOR[/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2] = (USER_FLASH_START & 0x1FFFFF80);[/SIZE][/FONT][/COLOR]


[COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]// Load contents of second word of user flash - the reset handler address[/SIZE][/FONT][/COLOR]
[COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]// in the applications vector table[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]p = ([/SIZE][/FONT][/COLOR][COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]unsigned[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2] *)(USER_FLASH_START +4);[/SIZE][/FONT][/COLOR]


[COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]// Set user_code_entry to be the address contained in that second word[/SIZE][/FONT][/COLOR]
[COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]// of user flash[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]user_code_entry[/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2] = ([/SIZE][/FONT][/COLOR][COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]void[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2] *) *p;[/SIZE][/FONT][/COLOR]


[COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]// Jump to user application[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]user_code_entry[/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2]();[/SIZE][/FONT][/COLOR]


[COLOR=#000000][FONT=Courier New, serif][SIZE=2]}[/SIZE][/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana, serif]---------------------------------------------------------------------------------------------[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana, serif]Plz anyone can explain this function logic???[/FONT][/COLOR]
0 Kudos
Reply

3,958 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Hareesha on Wed Feb 29 02:02:35 MST 2012
Hi gbm,




I got how to create .HEX file that procedure is as follows
[LIST]
[*]Right click on Project name,
[*]Go to properties
[*]C/C++ Build
[*]Settings
[*]Build steps
[*]Post build steps
[/LIST]Command:
Here replaced before command with following command
[COLOR=#00b050][B]arm-none-eabi-size ${BuildArtifactFileName}; arm-none-eabi-objcopy -O ihex ${BuildArtifactFileName} ${BuildArtifactFileBaseName}.hex ;[/B][/COLOR]

Then apply and save,
Then build as usually and checked in debug folder, here I got [B]Test.hex[/B] file.

Above procedure I applied for LED blinking and empty projects It works properly, [B]Bit if I apply same procedure to my boot loader code I got error. I attached that error screen shot.[/B]
[B]So what to do for that error???[/B]
AND
Now I am developing VC++ code in PC side that will read .hex file and send ASCII data to COM port. Then I ll use UART0 in controller side to read these ASCII data and Will write to flash memory
0 Kudos
Reply

3,958 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Hareesha on Wed Feb 29 01:58:39 MST 2012
Hi Angelo ,

Yes I didnt noticed that, Thnks for correcting.
0 Kudos
Reply

3,958 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Polux rsv on Wed Feb 29 01:17:57 MST 2012

Quote: Hareesha
[COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]// Initialize all required peripherals[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2][COLOR=Red]UART0_Init(115200);[/COLOR] [/SIZE][/FONT][/COLOR][COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]//Initialize UART 0[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]SystemInit();[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]SystemCoreClockUpdate();[/SIZE][/FONT][/COLOR]



Initialize the uart speed AFTER system and clock initialisation.

Angelo
0 Kudos
Reply

3,958 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by gbm on Tue Feb 28 07:25:16 MST 2012
What I like the best in your code is this:

[COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]//key_Pressed = 1; Means key not pressed

[/SIZE][/FONT][/COLOR]I would extend this brilliant idea of yours to something like:

if (everything_ok)
    ;// handle the error
else
    ;// proceed normally


Why don't you search the almighty Internet for some .HEX file loaders? You will get some basic ideas, then maybe after a few weeks of studying the programs written by other people you will be able to implement your own loader.

Another possibility: look at NXP download protocol, described in LPC manuals (it's not a nice one due to the use of decimal numbers, but it works anyway).
0 Kudos
Reply

3,958 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Hareesha on Tue Feb 28 06:02:46 MST 2012
[COLOR=#00b050][FONT=Courier New, serif][SIZE=2][B]Hi All,[/B][/SIZE][/FONT][/COLOR]


[COLOR=#00b050][FONT=Courier New, serif][SIZE=2][B]Once see my logic for RS485 boot loader and plz let me know is it correct or not, If wrong plz give me the suggestions to correct. [/B][/SIZE][/FONT][/COLOR]
[COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]-----------------------------------------------------------------------------[/B][/SIZE][/FONT][/COLOR]
[COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]-----------------------------------------------------------------------------[/B][/SIZE][/FONT][/COLOR]
[COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]#include[/B][/SIZE][/FONT][/COLOR][COLOR=#2a00ff][FONT=Courier New, serif][SIZE=2]"LPC17xx.h"[/SIZE][/FONT][/COLOR]


[COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]int[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2][B]main[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2] ([/SIZE][/FONT][/COLOR][COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]void[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2])[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]{[/SIZE][/FONT][/COLOR]
[COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]// Write boot loader code into 0th and 1st sector.[/SIZE][/FONT][/COLOR]
[COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]// [/SIZE][/FONT][/COLOR][COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2][U]int[/U][/SIZE][/FONT][/COLOR][COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2] SP = SECTOR_0_START;[/SIZE][/FONT][/COLOR]
[COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]// [/SIZE][/FONT][/COLOR][COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2][U]int[/U][/SIZE][/FONT][/COLOR][COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2] PC = SECTOR_0_START;[/SIZE][/FONT][/COLOR]
[COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]// Initialize all required peripherals[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]UART0_Init(115200); [/SIZE][/FONT][/COLOR][COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]//Initialize UART 0[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]SystemInit();[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]SystemCoreClockUpdate();[/SIZE][/FONT][/COLOR]


[COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]// Call timer or watch dog timer and wait for some second and within //this time user can press key if he want to down load the code through boot //loader.[/SIZE][/FONT][/COLOR]


[COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]// Whenever MCU get reset wait for 5 second and check port pin (SWITCH) //is low, If port pin (SWITCH) is LOW then enter into boot loader mode //otherwise execute previous code.[/SIZE][/FONT][/COLOR]


[COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]// And also check checksum of previous down loaded code, If there is //any error in the checksum then don't execute its previous code and wait for //boot loading mode.[/SIZE][/FONT][/COLOR]


[COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]//Check whether valid user code is present and its checksum is valid.[/SIZE][/FONT][/COLOR]
[COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]//FALSE(0) = User code is invalid OR checksum is invalid.[/SIZE][/FONT][/COLOR]
[COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]//TRUE(1) = User code is valid AND checksum is valid.[/SIZE][/FONT][/COLOR]


[COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]for[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2](j = 500000000; j > 0; j--);[/SIZE][/FONT][/COLOR][COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]// To give some delay, Within this time press key if u want to down load code through boot loader.[/SIZE][/FONT][/COLOR]


[COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]int[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2] key_Pressed = check_isp_entry_pin();[/SIZE][/FONT][/COLOR]
[COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]//key_Pressed = 0; Means key pressed and need boot loading mode[/SIZE][/FONT][/COLOR]
[COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]//key_Pressed = 1; Means key not pressed and no need boot loading mode[/SIZE][/FONT][/COLOR]


[COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]if[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2](!(user_code_present()) && !(key_Pressed))[/SIZE][/FONT][/COLOR]
[COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]//User want boot loading mode and user code or check sum is invalid then come //to boot loading mode[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]{[/SIZE][/FONT][/COLOR]
[COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]// BOOT LOADING mode[/SIZE][/FONT][/COLOR]
[COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]//save current SP (Stack Pointer) & PC (Program Counter)locations into variables[/SIZE][/FONT][/COLOR]
[COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]int[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2] SP = XXXX;[/SIZE][/FONT][/COLOR]
[COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]int[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2] PC = XXXX;[/SIZE][/FONT][/COLOR]


[COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]// make connection between BOADR and PC through UART[/SIZE][/FONT][/COLOR]


[COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]char[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2] Uart_Received[]= UART0_Getstring(*pcString); [/SIZE][/FONT][/COLOR][COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]// Receive data[/SIZE][/FONT][/COLOR]


[COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]// Uart_Received[] contains data which is written to flash[/SIZE][/FONT][/COLOR]
[COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]// Write Uart_Received[]data into flash from 3rd sector[/SIZE][/FONT][/COLOR]
[COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]//unsigned write_flash(unsigned * [/SIZE][/FONT][/COLOR][COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2][U]dst[/U][/SIZE][/FONT][/COLOR][COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2], char * [/SIZE][/FONT][/COLOR][COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2][U]src[/U][/SIZE][/FONT][/COLOR][COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2], unsigned no_of_bytes)[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]no_of_bytes = ox0007FFFF;[/SIZE][/FONT][/COLOR]
[COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]unsigned[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2][B]write_flash[/B][/SIZE][/FONT][/COLOR][COLOR=#000000][FONT=Courier New, serif][SIZE=2](* sector_start_map[2], * Uart_Received[], no_of_bytes);[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]}[/SIZE][/FONT][/COLOR]
[COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]//If invalid code, invalid checksum and user not pressed key to boot then execute present existing code itself.[/SIZE][/FONT][/COLOR]
[COLOR=#7f0055][FONT=Courier New, serif][SIZE=2][B]else[/B][/SIZE][/FONT][/COLOR]
[COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]//User don't want boot loading mode and user code & check sum are valid then execute present existing code[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]{[/SIZE][/FONT][/COLOR]


[COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]//Update SP (Stack Pointer) & PC (Program Counter) locations form second sector location to execute previous code.[/SIZE][/FONT][/COLOR]
[COLOR=#3f7f5f][FONT=Courier New, serif][SIZE=2]//SECTOR_2_START[/SIZE][/FONT][/COLOR]


[COLOR=#000000][FONT=Courier New, serif][SIZE=2]}[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Courier New, serif][SIZE=2]}[/SIZE][/FONT][/COLOR]
[FONT=Courier New][SIZE=2][/SIZE][/FONT]
[FONT=Courier New][SIZE=2][/SIZE][/FONT]
[FONT=Courier New][SIZE=2][/SIZE][/FONT]
0 Kudos
Reply