Skip to content

An example of a simple XMODEM serial bootloader for Renesas RL78

License

Notifications You must be signed in to change notification settings

iarsystems/ewrl78-bootloader

Repository files navigation

A simple XMODEM serial boot loader
for the Renesas RL78 Microcontroller

Overview

This repository hosts a workspace featuring a single project: rl78-boot. This project includes both the bootloader, which utilizes the Renesas Code Flash Self-Programming Library for RL78, and the application itself. The flashing process is performed via a serial port using the XMODEM protocol to ensure file transfer integrity.

Requirements

The bootloader project in this repo used the following software and hardware components

Note

  • Newer versions might work with little or no modifications.
  • Renesas Applilet3 for RL78 was used for setting up the involved peripherals. The configuration file rl78-boot.cgp is available, for reference.

Setup the YRPBRL78G13 board

The Renesas Promotion Board for RL78 conveniently comes with a built-in Serial-to-USB adapter which simplifies the initial setup.

  1. Make sure the Virtual UART is selected.
Jumper Configuration
J6 2-3
J7 2-3
J8 2-3
J9 2-3
  1. Use the E1 Emulator 14-pin flat cable to connect to the board J5 header.
  2. Use one mini-B USB cable to connect the Renesas E1 emulator to a PC USB port.
  3. Use another mini-B USB cable to connect the USB1 connector to another PC USB port.
  4. Use the Windows Device Manager to find out if the device was properly recognized and, if so, which communications port was assigned to it (e.g. COMx).

Get the code

The serial_bootloader workspace contains the rl78-boot project and can be cloned directly (or downloaded):

$ git clone https://github.com/iarsystems/ewrl78-bootloader

Connect to the serial port with Tera Term

  1. Switch to the Tera Term.
  2. Open a new serial connection using the COMx.
  3. Set the serial port parameters to 115200-8-N-1.

Build with IAR Embedded Workbench

To build the project, perform the following steps:

  1. Install the RL78 FSL library (for IAR compiler version 2.10+):

RENESAS_RL78_FSL_T01_4V00_b7YSmzOmeE

  1. Install it in the <path-to>/ewrl78-bootloader/rl78-boot/FSL. For example:

image

  1. In the IAR Embedded Workbench, load the serial_bootloader.eww workspace.
  2. Build the project (F7).
  3. Choose ProjectDownloadDownload active application.
  4. Disconnect the E1 Emulator from the YRPBRL78G13 J5 header.

In Tera Term, you should see the application V1 running, with the LED blinking on the board:

image

Updating the firmware

  1. In the project, modify the welcome string from V1 to V2 in the main-app.c source file and rebuild the project (F7).
  2. The application can enter into its "bootloader mode". Press b:

image

  1. The application is now in "bootloader mode" from where it is possible to download a new firmware. Press 1:

image

  1. Choose FileTransferXMODEMSend..., navigate to the file Debug\Exe\boot+app.bin and click Send:

image

Congratulations! The bootloader updated the application:

image

Memory layout

The memory layout was defined for the R5F100LE device:

Region Start End Description
BOOT0_ROM 0x00000 0x00FFF The bootloader region
BOOT1_ROM 0x01000 0x01FFF The bootloader update slot
APPLICATION 0x02000 0x0FFFF The main application

Note

  • The linker configuration file (boot_lnkr5f100le.icf) serves as an example for other RL78 compatible parts.
  • The BOOT1_ROM region is unmapped, solely used as temporary storage space for a new bootloader(, interrupt vectors, etc.).

Post build

The following command is performed during the post-build stage (ProjectOptionsBuild Actions):

ielftool --bin-multi="0x00000-0x00FFF;0x02000-0x0FFFF" "$TARGET_PATH$" "$EXE_DIR$\binfile" & copy /b/v "$EXE_DIR$\binfile-0x0"+"$EXE_DIR$\binfile-0x2000" "$EXE_DIR$\boot+app.bin"

This build action will:

  1. Use the IAR ELF Tool to generate 2 binary files: one for BOOT0_ROM and another one for APPLICATION.
  2. Use the copy /b command to concatenate the generated binary files into a single boot+app.bin binary file.

Issues

For technical support contact IAR Customer Support.

For questions or suggestions related to this repository: try the wiki or check earlier issues. If those don't help, create a new issue with detailed information.