diff --git a/configs/makerlisp/Kconfig b/configs/makerlisp/Kconfig
index c1fd169749e..d9bf5fb64c5 100644
--- a/configs/makerlisp/Kconfig
+++ b/configs/makerlisp/Kconfig
@@ -12,4 +12,12 @@ config MAKERLISP_VGA
Select this option if you have an I/O Controller and a VGA vide card
connected.
+config MAKERLISP_SDBOOT
+ bool "Build SD boot loader"
+ default n
+ ---help---
+ Select this option only with the configs/makerlisp/sdboot
+ configuration. This will enable the components needed only by the
+ boot loader.
+
endif # ARCH_BOARD_MAKERLISP
diff --git a/configs/makerlisp/README.txt b/configs/makerlisp/README.txt
index a72c5ffcafb..7831dbf146b 100644
--- a/configs/makerlisp/README.txt
+++ b/configs/makerlisp/README.txt
@@ -274,7 +274,7 @@ Configuration Subdirectories
NOTES:
- 1. The two configurations different only in that cone builds for
+ 1. The two configurations different only in that one builds for
execution from FLASH and the other for execution from RAM. A
bootloader of some kind is required to support execution from RAM!
This difference is reflected in a single configuration setting:
@@ -396,3 +396,18 @@ Configuration Subdirectories
2019-06-26: Renamed nsh configuration to nsh_flash. Added nsh_ram
configuration.
+
+ sdboot
+
+ This configuration implements a very simple boot loader. In runs from
+ FLASH and simply initializes the external SRAM, mounts the FAT file
+ system on the SD card, and checks to see if there is a file called
+ nuttx.hex on the SD card. If so, it will load the Intel HEX file into
+ memory and jump to address 0x040000. This, of course, assumes that
+ the application's reset vector resides at address 0x040000 in external
+ SRAM.
+
+ The boot loader source is located at configs/makerlisp/src/sd_main.c.
+
+ STATUS:
+ 2019-06-26: Configuration added. Not yet verified.
diff --git a/configs/makerlisp/sdboot/.gitignore b/configs/makerlisp/sdboot/.gitignore
new file mode 100644
index 00000000000..739b8373b85
--- /dev/null
+++ b/configs/makerlisp/sdboot/.gitignore
@@ -0,0 +1,7 @@
+nsh.hex
+nsh.map
+nsh.lod
+nsh.wsp
+*.asm
+Debug
+
diff --git a/configs/makerlisp/sdboot/README.txt b/configs/makerlisp/sdboot/README.txt
new file mode 100644
index 00000000000..75ef350f0f8
--- /dev/null
+++ b/configs/makerlisp/sdboot/README.txt
@@ -0,0 +1,13 @@
+README.txt
+^^^^^^^^^^
+
+sdboot.zdsproj is a simple ZDS-II project that will allow you
+ to use the ZDS-II debugger.
+sdboot.zfpproj is a simple project that will allow you to use the Smart Flash
+ Programming. NOTE: As of this writing this project does not work, probably
+ due to RAM configuration in the project. Use ZDS-II instead as is described
+ in the upper README.txt file
+sdboot_flash.ztgt is the target file that accompanies the project files. This
+ one is identical to configs/scripts/makerlisp_ram.ztgt.
+sdboot_ram.ztgt is the target file that accompanies the project files. This
+ one is identical to configs/scripts/makerlisp_flash.ztgt.
diff --git a/configs/makerlisp/sdboot/defconfig b/configs/makerlisp/sdboot/defconfig
new file mode 100644
index 00000000000..d1e37968849
--- /dev/null
+++ b/configs/makerlisp/sdboot/defconfig
@@ -0,0 +1,51 @@
+#
+# This file is autogenerated: PLEASE DO NOT EDIT IT.
+#
+# You can use "make menuconfig" to make any modifications to the installed .config file.
+# You can then do "make savedefconfig" to generate a new defconfig file that includes your
+# modifications.
+#
+# CONFIG_MMCSD_HAVE_CARDDETECT is not set
+# CONFIG_MMCSD_HAVE_WRITEPROTECT is not set
+# CONFIG_MMCSD_MMCSUPPORT is not set
+# CONFIG_SPI_CALLBACK is not set
+CONFIG_ARCH="z80"
+CONFIG_ARCH_BOARD="makerlisp"
+CONFIG_ARCH_BOARD_MAKERLISP=y
+CONFIG_ARCH_CHIP_EZ80=y
+CONFIG_ARCH_CHIP_EZ80F91=y
+CONFIG_ARCH_STACKDUMP=y
+CONFIG_ARCH_Z80=y
+CONFIG_BOARD_LOOPSPERMSEC=1250
+CONFIG_DISABLE_MQUEUE=y
+CONFIG_EZ80_SPI=y
+CONFIG_EZ80_UART0=y
+CONFIG_FAT_LCNAMES=y
+CONFIG_FAT_LFN=y
+CONFIG_FS_FAT=y
+CONFIG_HOST_WINDOWS=y
+CONFIG_LIB_HEX2BIN=y
+CONFIG_MAKERLISP_SDBOOT=y
+CONFIG_MAX_TASKS=8
+CONFIG_MAX_WDOGPARMS=2
+CONFIG_MMCSD=y
+CONFIG_MMCSD_MULTIBLOCK_DISABLE=y
+CONFIG_NFILE_DESCRIPTORS=6
+CONFIG_NFILE_STREAMS=6
+CONFIG_PREALLOC_TIMERS=4
+CONFIG_PREALLOC_WDOGS=4
+CONFIG_PTHREAD_STACK_DEFAULT=1024
+CONFIG_RAM_SIZE=65536
+CONFIG_RR_INTERVAL=200
+CONFIG_SCHED_HPWORK=y
+CONFIG_SDCLONE_DISABLE=y
+CONFIG_SPI=y
+CONFIG_START_DAY=26
+CONFIG_START_MONTH=6
+CONFIG_START_YEAR=2019
+CONFIG_UART0_BITS=0
+CONFIG_UART0_RXBUFSIZE=192
+CONFIG_UART0_SERIAL_CONSOLE=y
+CONFIG_UART0_TXBUFSIZE=64
+CONFIG_USER_ENTRYPOINT="sd_main"
+CONFIG_WDOG_INTRESERVE=1
diff --git a/configs/makerlisp/sdboot/sdboot.zdsproj b/configs/makerlisp/sdboot/sdboot.zdsproj
new file mode 100644
index 00000000000..c8332638354
--- /dev/null
+++ b/configs/makerlisp/sdboot/sdboot.zdsproj
@@ -0,0 +1,261 @@
+
+eZ80F91
+
+
+
+..\..\..\nuttx.hex
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/configs/makerlisp/sdboot/sdboot.zfpproj b/configs/makerlisp/sdboot/sdboot.zfpproj
new file mode 100644
index 00000000000..3a82e2c4092
--- /dev/null
+++ b/configs/makerlisp/sdboot/sdboot.zfpproj
@@ -0,0 +1,315 @@
+
+eZ80F91
+
+
+
+..\..\..\nuttx.hex
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/configs/makerlisp/sdboot/sdboot_flash.ztgt b/configs/makerlisp/sdboot/sdboot_flash.ztgt
new file mode 100644
index 00000000000..d314f59bff2
--- /dev/null
+++ b/configs/makerlisp/sdboot/sdboot_flash.ztgt
@@ -0,0 +1,69 @@
+
+
+
+
+ true
+ 1f4
+ 8
+ 5000000
+
+ PLL
+ 50000000
+
+
+ 0
+ 140000
+ FFFF
+ true
+
+
+
+ 200000
+ false
+ 40000
+ 13FFFF
+
+ 1
+ false
+ true
+
+
+
+
+ 0
+ 8
+ 4
+ B
+
+
+ 0
+ 8
+ C
+ 13
+
+
+ 0
+ 88
+ 20
+ 9F
+
+
+ 0
+ 0
+ 0
+ 0
+
+
+
+ 0
+ AF
+ true
+ true
+ false
+
+ 4
+
+ EZ80F91
+ 1.0.1
+ 1.00
+
diff --git a/configs/makerlisp/sdboot/sdboot_ram.ztgt b/configs/makerlisp/sdboot/sdboot_ram.ztgt
new file mode 100644
index 00000000000..478b8a26d44
--- /dev/null
+++ b/configs/makerlisp/sdboot/sdboot_ram.ztgt
@@ -0,0 +1,69 @@
+
+
+
+
+ true
+ 1f4
+ 8
+ 5000000
+
+ PLL
+ 50000000
+
+
+ 0
+ 100000
+ ffff
+ true
+
+
+
+ 200000
+ false
+ 000000
+ FFFFF
+
+ 1
+ false
+ true
+
+
+
+
+ 0
+ 8
+ 0
+ 7
+
+
+ 0
+ 8
+ 8
+ F
+
+
+ 0
+ 28
+ 20
+ 9F
+
+
+ 0
+ 0
+ 0
+ 0
+
+
+
+ 0
+ AF
+ false
+ true
+ false
+
+ 4
+
+ EZ80F91
+ 1.0.1
+ 1.00
+
diff --git a/configs/makerlisp/src/Makefile b/configs/makerlisp/src/Makefile
index a7ba65be604..1c1383c8889 100644
--- a/configs/makerlisp/src/Makefile
+++ b/configs/makerlisp/src/Makefile
@@ -53,4 +53,8 @@ CSRCS += ez80_spimmcsd.c
endif
endif
+ifeq ($(CONFIG_MAKERLISP_SDBOOT),y)
+CSRCS += sd_main.c
+endif
+
include $(TOPDIR)/configs/Board.mk
diff --git a/configs/makerlisp/src/sd_main.c b/configs/makerlisp/src/sd_main.c
index 1a8f7f2c302..de43d81b5c6 100644
--- a/configs/makerlisp/src/sd_main.c
+++ b/configs/makerlisp/src/sd_main.c
@@ -40,9 +40,12 @@
#include
#include
+#include
#include
#include
#include
+#include
+#include
#include
@@ -56,8 +59,12 @@
#define MMCSD_MOUNTPT "/mnt/sdcard"
#define MMCSD_HEXFILE "/mnt/sdcard/nuttx.hex"
-#define SRAM_RESET 0x040000
-#define SRAM_ENTRY ((sram_entry_t)SRAM_RESET)
+#define SRAM_START 0x040000
+#define SRAM_SIZE 0x100000
+#define SRAM_END (SRAM_START + SRAM_SIZE)
+
+#define SRAM_RESET SRAM_START
+#define SRAM_ENTRY ((sram_entry_t)SRAM_START)
/****************************************************************************
* Private Types
@@ -94,7 +101,7 @@ int sd_main(int argc, char *argv)
* the MMC/SD block driver at /dev/mmcsd0.
*/
- DEBUG_VERIFY(ez80_bringup());
+ DEBUGVERIFY(ez80_bringup());
#endif
syslog(LOG_INFO, "Loading %s\n", MMCSD_HEXFILE);
@@ -123,15 +130,12 @@ int sd_main(int argc, char *argv)
/* Load the HEX image into memory */
- ret = hex2mem(fd,
- (uint32_t)SAM_DDRCS_VSECTION,
- (uint32_t)(SAM_DDRCS_VSECTION + CONFIG_SAMA5_DDRCS_SIZE),
- 0);
+ ret = hex2mem(fd, (uint32_t)SRAM_START, (uint32_t)SRAM_END, 0);
if (ret < 0)
{
/* We failed to load the HEX image */
- printf("ERROR: Intel HEX file load failed: %d\n", ret);
+ syslog(LOG_ERR, "ERROR: Intel HEX file load failed: %d\n", ret);
goto halt_with_hexfile;
}
@@ -152,6 +156,7 @@ int sd_main(int argc, char *argv)
/* Then jump into SRAM via the reset vector at 0x040000 */
SRAM_ENTRY();
+ goto halt;
halt_with_hexfile:
close(fd);
diff --git a/include/hex2bin.h b/include/hex2bin.h
index f971bf8a874..c3148e768b9 100644
--- a/include/hex2bin.h
+++ b/include/hex2bin.h
@@ -43,6 +43,7 @@
#include
#include
+#include
#ifdef CONFIG_LIB_HEX2BIN
diff --git a/libs/libc/misc/Make.defs b/libs/libc/misc/Make.defs
index 230d289dc5f..02e60fd6e8b 100644
--- a/libs/libc/misc/Make.defs
+++ b/libs/libc/misc/Make.defs
@@ -1,7 +1,7 @@
############################################################################
# libs/libc/misc/Make.defs
#
-# Copyright (C) 2011-2012, 2014, 2016, 2018 Gregory Nutt. All rights
+# Copyright (C) 2011-2012, 2014, 2016, 2018-2019 Gregory Nutt. All rights
# reserved.
# Author: Gregory Nutt
#
@@ -67,11 +67,7 @@ endif
# Add the miscellaneous C files to the build
CSRCS += lib_crc64.c lib_crc32.c lib_crc16.c lib_crc8.c lib_crc8ccitt.c
-CSRCS += lib_dumpbuffer.c lib_match.c
-
-ifeq ($(CONFIG_DEBUG_FEATURES),y)
-CSRCS += lib_debug.c
-endif
+CSRCS += lib_dumpbuffer.c lib_match.c lib_debug.c
# Keyboard driver encoder/decoder
diff --git a/libs/libc/misc/lib_debug.c b/libs/libc/misc/lib_debug.c
index 31fa0505e77..f9aeb29a216 100644
--- a/libs/libc/misc/lib_debug.c
+++ b/libs/libc/misc/lib_debug.c
@@ -1,8 +1,8 @@
/****************************************************************************
* libs/libc/misc/lib_err.c
*
- * Copyright (C) 2007-2009, 2011-2012, 2016, 2018 Gregory Nutt. All rights
- * reserved.
+ * Copyright (C) 2007-2009, 2011-2012, 2016, 2018-2019 Gregory Nutt. All
+ * rights reserved.
* Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without