diff --git a/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/README.md b/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/README.md index 77ed9cf2e6..4ff12603c1 100644 --- a/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/README.md +++ b/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/README.md @@ -21,16 +21,24 @@ Step 2: Copy MS64\dll\libusb-1.0.dll to C:\Windows\System32. Step 3: Copy MS64\dll\libusb-1.0.lib to C:\Users\\AppData\Local\Programs\Python\\Lib. ``` -## Scripts +## Double-click Scripts for Windows ### nuwriter_ddr_download_and_run.bat -Download rttthread binary file into DDR. The address is 0x80400000. +Download rtthread.bin binary file into DDR. The address is 0x80400000. -### nuwriter_nand_programming.bat +### nuwriter_sd_programming.bat -Program header, DDR timing setting and rttthread binary file into NAND flash. +Program header, DDR timing setting and rtthread.bin binary file into SD card or EMMC. ### nuwriter_spinand_programming.bat -Program header, DDR timing setting and rttthread binary file into SPI NAND flash. +Program header, DDR timing setting and rtthread.bin binary file into SPI NAND flash. + +### nuwriter_nand_programming.bat + +Program header, DDR timing setting and rtthread.bin binary file into NAND flash. + + +### See also +[NuWriter Repository](https://github.com/OpenNuvoton/MA35D1_NuWriter) diff --git a/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/UnpackImage.py b/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/UnpackImage.py index 29ae007767..113f6fe307 100644 --- a/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/UnpackImage.py +++ b/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/UnpackImage.py @@ -8,7 +8,7 @@ import crcmod class UnpackImage: - def __init__(self, pack_file_name): + def __init__(self, pack_file_name, nocrc): self.img_list = [] try: with open(pack_file_name, "rb") as pack_file: @@ -21,11 +21,14 @@ class UnpackImage: print(f"{pack_file_name} marker check failed") sys.exit(0) - crc32_func = crcmod.predefined.mkCrcFun('crc-32') - checksum = crc32_func(self.pack_data[8:]) - if checksum != int.from_bytes(self.pack_data[4:8], byteorder='little'): - print(f"{pack_file_name} CRC check failed") - sys.exit(0) + print("Waiting for unpack Images ...") + if nocrc == 0: + print("check pack file crc32 ...") + crc32_func = crcmod.predefined.mkCrcFun('crc-32') + checksum = crc32_func(self.pack_data[8:]) + if checksum != int.from_bytes(self.pack_data[4:8], byteorder='little'): + print(f"{pack_file_name} CRC check failed") + sys.exit(0) self.image_cnt = int.from_bytes(self.pack_data[8:12], byteorder='little') # 1st image descriptor begins @ 0x10 index = 0x10 diff --git a/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/_nuwriter_nand_generate_header_bin.bat b/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/_nuwriter_nand_generate_header_bin.bat deleted file mode 100644 index 90242c39c5..0000000000 --- a/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/_nuwriter_nand_generate_header_bin.bat +++ /dev/null @@ -1,2 +0,0 @@ -py -3 nuwriter.py -c header-nand.json -pause diff --git a/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/_nuwriter_nand_generate_pack_bin.bat b/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/_nuwriter_nand_generate_pack_bin.bat deleted file mode 100644 index 80110b5deb..0000000000 --- a/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/_nuwriter_nand_generate_pack_bin.bat +++ /dev/null @@ -1,2 +0,0 @@ -py -3 nuwriter.py -p pack-nand.json -pause \ No newline at end of file diff --git a/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/ddrimg/enc_ddr2_winbond_128mb.bin b/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/ddrimg/enc_ddr2_winbond_128mb.bin new file mode 100644 index 0000000000..3ac079800b Binary files /dev/null and b/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/ddrimg/enc_ddr2_winbond_128mb.bin differ diff --git a/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/ddrimg/enc_ddr3_winbond_256mb.bin b/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/ddrimg/enc_ddr3_winbond_256mb.bin new file mode 100644 index 0000000000..6f64bd68ff Binary files /dev/null and b/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/ddrimg/enc_ddr3_winbond_256mb.bin differ diff --git a/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/nuwriter.py b/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/nuwriter.py index a9dfea35b5..60ae52747b 100644 --- a/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/nuwriter.py +++ b/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/nuwriter.py @@ -63,6 +63,7 @@ OPT_STUFF = 7 # For stuff pack, output could be used by dd command OPT_SETINFO = 8 # For set storage info for attach OPT_CONCAT = 9 # For convert, concatenate at the end of encrypted data file OPT_SHOWHDR = 10 # For convert. Instead of convert, show header content instead +OPT_NOCRC = 11 # For pack. unpack file without crc32 check OPT_UNKNOWN = 0xFF # Error @@ -765,7 +766,7 @@ def do_pack_program(media, pack_file_name, option=OPT_NONE) -> None: print("Device not found") sys.exit(2) - pack_image = UnpackImage(pack_file_name) + pack_image = UnpackImage(pack_file_name, option) with ThreadPoolExecutor(max_workers=8) as executor: futures = [executor.submit(__pack_program, dev, media, pack_image, option) for dev in devices] success = 0 @@ -1179,10 +1180,10 @@ def do_attach(ini_file_name, option=OPT_NONE) -> None: print(f"Successfully get info from {success} device(s)") -def do_unpack(pack_file_name) -> None: +def do_unpack(pack_file_name, nocrc32) -> None: now = datetime.now() - pack_image = UnpackImage(pack_file_name) + pack_image = UnpackImage(pack_file_name, nocrc32) image_cnt = pack_image.img_count() try: @@ -1681,7 +1682,8 @@ def get_option(option) -> int: 'STUFF': OPT_STUFF, 'SETINFO': OPT_SETINFO, 'CONCAT': OPT_CONCAT, - 'SHOWHDR': OPT_SHOWHDR + 'SHOWHDR': OPT_SHOWHDR, + 'NOCRC': OPT_NOCRC }.get(option, OPT_UNKNOWN) @@ -1772,7 +1774,9 @@ def main(): sys.exit(0) else: if option == OPT_UNPACK: - do_unpack(cfg_file) + do_unpack(cfg_file, 0) + elif option == OPT_NOCRC: + do_unpack(cfg_file, 1) elif option == OPT_STUFF: do_stuff(cfg_file) else: diff --git a/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/nuwriter_leave_ibr_download_and_run.bat b/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/nuwriter_leave_ibr_download_and_run.bat deleted file mode 100644 index f60706d163..0000000000 --- a/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/nuwriter_leave_ibr_download_and_run.bat +++ /dev/null @@ -1,8 +0,0 @@ -:forever_develop -py -3 nuwriter.py -a ddrimg\enc_ddr3_winbond_256mb.bin -IF %ERRORLEVEL% EQU 0 ( - py -3 nuwriter.py -o execute -w ddr 0x28000000 ..\preload\leave_ibr.bin -) -pause - -goto :forever_develop \ No newline at end of file diff --git a/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/nuwriter_leave_ibr_sd_pack.bat b/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/nuwriter_leave_ibr_sd_pack.bat deleted file mode 100644 index c1deb2296f..0000000000 --- a/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/nuwriter_leave_ibr_sd_pack.bat +++ /dev/null @@ -1,5 +0,0 @@ -py -3 nuwriter.py -c header-sram-leave_ibr.json -IF %ERRORLEVEL% EQU 0 ( - py -3 nuwriter.py -p pack-sd-leave_ibr.json -o stuff -) -pause \ No newline at end of file diff --git a/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/otp_writer.bin b/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/otp_writer.bin new file mode 100644 index 0000000000..2aa82e32b9 Binary files /dev/null and b/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/otp_writer.bin differ diff --git a/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/xusb.bin b/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/xusb.bin new file mode 100644 index 0000000000..47ae8d4b47 Binary files /dev/null and b/bsp/nuvoton/numaker-hmi-ma35d1/nuwriter_scripts/xusb.bin differ diff --git a/bsp/nuvoton/numaker-hmi-ma35d1/preload/Makefile.leave_ibr b/bsp/nuvoton/numaker-hmi-ma35d1/preload/Makefile.leave_ibr deleted file mode 100644 index d0e949ca1c..0000000000 --- a/bsp/nuvoton/numaker-hmi-ma35d1/preload/Makefile.leave_ibr +++ /dev/null @@ -1,69 +0,0 @@ -TARGET ?= leave_ibr - -################################# -# GNU ARM Embedded Toolchain -################################# -CC=aarch64-elf-gcc -CXX=aarch64-elf-g++ -LD=aarch64-elf-ld -AR=aarch64-elf-ar -AS=aarch64-elf-as -CP=aarch64-elf-objcopy -OD=aarch64-elf-objdump -NM=aarch64-elf-nm -SIZE=aarch64-elf-size -A2L=aarch64-elf-addr2line - -################################# -# Working directories -################################# -ROOT = . - -################################# -# Source Files -################################# - -# Search path and source files for the ST stdperiph library - -ASMSOURCES = $(notdir $(wildcard *.ASM)) - -INCLUDE_DIRS = -I$(ROOT) - -################################# -# Object List -################################# -OBJECTS= - -################################# -# Target Output Files -################################# -TARGET_O=$(TARGET).o -TARGET_ASM=$(TARGET).asm - -################################# -# Flags -################################# -MCFLAGS=-march=armv8-a -OPTIMIZE = -O2 -AFLAGS=-c $(MCFLAGS) -x assembler-with-cpp -D__ASSEMBLY__ -LDSCRIPT= -LDFLAGS = -nostartfiles -Wl,--gc-sections,-cref,-Map=$(TARGET).map,-cref,-u,_start -T $(TARGET).ld - -################################# -# Build -################################# -all: clean $(TARGET_O) - -$(TARGET_O): - @echo -n "Build $@ ..." - $(CC) -c $(INCLUDE_DIRS) $(AFLAGS) $(ASMSOURCES) $(LDFLAGS) - $(OD) -d $@ > $(TARGET).txt - $(CP) -O binary $(TARGET_O) ../nuwriter_scripts/$(TARGET).bin - -################################# -# Recipes -################################# -.PHONY: all clean - -clean: - rm -f $(TARGET_O) \ No newline at end of file diff --git a/bsp/nuvoton/numaker-hmi-ma35d1/preload/env_build.bat b/bsp/nuvoton/numaker-hmi-ma35d1/preload/env_build.bat index ad8f1ad7b9..57136e7b8e 100644 --- a/bsp/nuvoton/numaker-hmi-ma35d1/preload/env_build.bat +++ b/bsp/nuvoton/numaker-hmi-ma35d1/preload/env_build.bat @@ -5,5 +5,3 @@ make python transcode.py - -make -f Makefile.leave_ibr diff --git a/bsp/nuvoton/numaker-hmi-ma35d1/preload/leave_ibr.ASM b/bsp/nuvoton/numaker-hmi-ma35d1/preload/leave_ibr.ASM deleted file mode 100644 index 91571076a7..0000000000 --- a/bsp/nuvoton/numaker-hmi-ma35d1/preload/leave_ibr.ASM +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2006-2020, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Date Author Notes - * 2021-06-29 Wayne the first version - * - * Description: Load the routine into SRAM0 0x28000000 - * - */ - -.section ".text.boot" -.global _start - -_start: - /* Give execution address for secondary CPU */ - adr x20, . - - /*=============================================================*/ - /* Read CPU id */ - /* Primary core(id=0): Help Secondary core leaving. */ - /* Secondary core(id>0): Notice 'Ready' to Primary core. */ - /*=============================================================*/ - /* MPIDR_EL1: Multi-Processor Affinity Register */ - mrs x1, mpidr_el1 - and x1, x1, #3 - cbz x1, .L__cpu_0_loop - -.L__cpu_1_loop: - /*=============================================================*/ - /* Secondary CPU notification */ - /*=============================================================*/ - wfe /* Wait for Primary CPU's notification */ - - mov x0, #0x48 /* if (*(0x40460048)==PC) */ - movk x0, #0x4046, LSL #16 /* goto L__cpu_1_loop */ - ldr x1, [x0] /* else */ - cmp x1, x20 /* goto *(0x40460048) */ - b.eq .L__cpu_1_loop - br x1 - -.L__cpu_0_loop: - /*=============================================================*/ - /* Help CPU-1 to leave IBR. */ - /*=============================================================*/ - mov x0, #0x48 /* *(0x40460048) = _start */ - movk x0, #0x4046, LSL #16 - mov x1, x20 - str w1, [x0] - sev /* Wakeup Secondary CPU */ - b .L__cpu_0_loop -