Learn more about the bootloader of the C language, please add my QQ: 1273623966 (authentication information please fill bootloader), welcomed the consultation or custom bootloader (online upgrade program).
Today I want to introduce RH850 bootloader only recently completed a serial bootloader. It RL78 bootloader is very similar, also in two parts, RH850 MCU end of the boot program rh850f1kmBoot, the other part is the PC host program rh850Loader with a communication agreement between them, communication protocol as follows:
0x6F: HAND_SHAKE (handshake, or call update request)
0x02: WR_MEM (Flash programming)
0x03: ER_MEM (Flash erase)
0x04: VF_MEM (Flash verification)
0x1F: RUN_APP (Jump to application)
rh850f1kmBoot development environment:
IDE: CS+ for CC V7.00.00 [13 Jun 2018]
Compiler: CC-RH V2.00.00
MCU: RH850 F1KM R7F701684
It uses flash library Renesas official offer: RENESAS_FCL_RH850_T01_V2.12
rh850f1kmBoot memory map (code flash range): 0x0000~0x17FFF;
And adds the following ROM sections:
R_FCL_CODE_ROM.text, &
R_FCL_CONST.const, &
R_FCL_CODE_USRINT.text, &
R_FCL_CODE_USR.text, &
R_FCL_CODE_RAM.text, &
R_FCL_CODE_ROMRAM.text, &
R_FCL_CODE_RAM_EX_PROT.text
And RAM sections:
FCL_RESERVED.bss/FEDE0000, &
R_FCL_DATA.bss, &
.stack.bss /FEDE8000
Are provided above with reference to Renesas flash library pacakge (FCL) inside the sample to do. Configuring the linker option CS + works well in these settings on it.
Configured, the rest is completed code.
if (R_UART1_RcvFlag()) { if (BTLD_FramePtr == 0) { uint8_t sof = R_UART1_FlagedReceive(); if ( sof != 0x02 && sof != 0x03 && sof != 0x04 && sof != 0x1F ) { ; } else { BTLD_ReceiveFrame[BTLD_FramePtr++] = sof; } } else { BTLD_ReceiveFrame[BTLD_FramePtr++] = R_UART1_FlagedReceive(); } } if (BTLD_FramePtr == FRAME_BUFF_SIZE) { uint8_t cmd = BTLD_ReceiveFrame[CMD_INDEX]; uint8_t addL = BTLD_ReceiveFrame[ADDRL_INDEX]; uint8_t addH = BTLD_ReceiveFrame[ADDRH_INDEX]; uint8_t addU = BTLD_ReceiveFrame[ADDRU_INDEX]; uint8_t addM = BTLD_ReceiveFrame[ADDRM_INDEX]; uint32_t add32 = ((uint32_t)addM << 24)|((uint32_t)addU << 16)|((uint32_t)addH << 8) | addL; BTLD_FramePtr = 0; switch (cmd) { case ER_MEM: BTLD_FlashErase(add32); resetDataBuffer(BTLD_ReceiveFrame, FRAME_BUFF_SIZE); break; case WR_MEM: BTLD_FlashWrite(add32); resetDataBuffer(BTLD_ReceiveFrame, FRAME_BUFF_SIZE); break; case VF_MEM: BTLD_FlashVerify(add32); break; case RUN_APP: Jump_To_Application(add32); break; default: break; } }
The above is achieved rh850f1kmBoot chip end. PC end rh850Loader is implemented in C #. After loading the hex address in accordance with the Agreement and data transmission via RS232.
RS232 configuration is as follows:. 19200-8-None-1- None (19200bps Baud Rate I is the most common of the UART).
rh850Loader with UI interface: