SDFileSystem and PokittoDisk not working 100% with latest library

I’m having trouble getting the SDFileSystem and PokittoDisk libraries working properly using the latest PokittoLib download from the git repo.

I have tried compiling the SDFileIO example using @drummyfish’s CLI compiling tutorial for linux. I also re-compiled Xplorito from source and it too is unable to properly access the SD card. The pre-built version that came on the SDCard is able to create/delete/rename files/folders and perform the bench test just fine.

What works:

  • SDFileSystem
    • Opening/Reading a file in O_RDONLY mode

What doesn’t work:

  • Anything involving PokittoDisk
  • SDFileSystem opening file in write mode
  • SDFileSystem creating a new file
  • SDFileSystem creating a new folder

I can’t get it to compile in mbed because the SDFileSystem is not in the POKITTO_LIBS sub-folder. When I imported the library marked “Official mbed SDFileSystem library” it gives an error about _VOLUMES not being defined despite it being present in the ffconfig.h file. I’ve tried using just PokittoDisk with mbed and it’s still not wanting to work following the SDFileIO example (replacing the path of the file it creates with a file that already exists).

Trying to do some various hardware tests to see just how far I can push the limits of this device. Sadly there seems to be little documentation or working examples using either SDFileSystem or PokittoDisk. I’ve spent countless hours pouring over any scrap of documentation and code examples I can find but still no luck.

Code wise this is being tested using the current PokittoLib in the git repo (and the subsequent SDFileIO example inside it) and the current Xplorito codebase from it’s git repo.

Can anyone else reproduce this (possibly with other compilers) using the those latest pieces of code?

1 Like

I am going to try this.

@bl_ackrain, could you try buildibg Xploritto?

i will try it this evening.

1 Like

Does it work if you use the Xploritto build provided by @bl_ackrain? Just to be sure it’s not an issue with your SD card’s file system.

Yes it works with the v0.1.1 bin file from the Xploritto forum post. Unfortunately I can’t seem to get SDFileSystem compiling with mbed. When I import the PokittoLib it only includes the POKITTO_LIBS/ImageFormat and POKITTO_LIBS/synth but nothing else.

Here’s the output of arm-eabi-none-g++ --version in case it helps
arm-none-eabi-g++ (GNU Tools for Arm Embedded Processors 9-2019-q4-major) 9.2.1 20191025 (release) [ARM/arm-9-branch revision 277599]

Also here's the Makefile
# This file was automagically generated by mbed.org. For more information, 
# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded

###############################################################################
# Boiler-plate

rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))

PROJECT := $(notdir $(CURDIR))
BPROJECT := build/$(PROJECT)
SOURCES_CPP := $(wildcard *.cpp)
#POKITTO_CPP := $(call rwildcard,PokittoLib/,*.cpp)
#POKITTO_C := $(call rwildcard,PokittoLib/,*.c)
OBJECTS := $(SOURCES_CPP:%.cpp=build/%.o)

#$(info $(SOURCES_CPP))
#$(error $(OBJECTS))

ifeq ($(OC),on)
	C_FLAGS += -D_OSCT=2
	CXX_FLAGS += -D_OSCT=2
	#$(info Overclocking)
else
	#$(info Not Overclocking)
endif

# cross-platform directory manipulation
ifeq ($(shell echo $$OS),$$OS)
	MAKEDIR = if not exist "$(1)" mkdir "$(1)"
	RM = rmdir /S /Q "$(1)"
else
	MAKEDIR = '$(SHELL)' -c "mkdir -p \"$(1)\""
	RM = '$(SHELL)' -c "rm -rf \"$(1)\""
endif

OBJDIR := build
SRCDIR := $(CURDIR)

.PHONY: clean

.SUFFIXES:
.SUFFIXES: .cpp .o

vpath %.cpp .
vpath %.c .
vpath %.h .

# Boiler-plate
###############################################################################
# Project settings

# Project settings
###############################################################################
# Objects and Paths

OBJECTS += build/PokittoLib/POKITTO_CORE/FONTS/TIC806x6.o
OBJECTS += build/PokittoLib/POKITTO_CORE/FONTS/ZXSpec.o
OBJECTS += build/PokittoLib/POKITTO_CORE/FONTS/adventurer12x16.o
OBJECTS += build/PokittoLib/POKITTO_CORE/FONTS/donut7x10.o
OBJECTS += build/PokittoLib/POKITTO_CORE/FONTS/dragon6x8.o
OBJECTS += build/PokittoLib/POKITTO_CORE/FONTS/font3x3.o
OBJECTS += build/PokittoLib/POKITTO_CORE/FONTS/font3x5.o
OBJECTS += build/PokittoLib/POKITTO_CORE/FONTS/font5x7.o
OBJECTS += build/PokittoLib/POKITTO_CORE/FONTS/fontC64.o
OBJECTS += build/PokittoLib/POKITTO_CORE/FONTS/fontC64UIGfx.o
OBJECTS += build/PokittoLib/POKITTO_CORE/FONTS/karateka8x11.o
OBJECTS += build/PokittoLib/POKITTO_CORE/FONTS/koubit7x7.o
OBJECTS += build/PokittoLib/POKITTO_CORE/FONTS/mini4x6.o
OBJECTS += build/PokittoLib/POKITTO_CORE/FONTS/runes6x8.o
OBJECTS += build/PokittoLib/POKITTO_CORE/FONTS/tight4x7.o
OBJECTS += build/PokittoLib/POKITTO_CORE/FONTS/tiny5x7.o
OBJECTS += build/PokittoLib/POKITTO_CORE/PALETTES/palAction.o
OBJECTS += build/PokittoLib/POKITTO_CORE/PALETTES/palCGA.o
OBJECTS += build/PokittoLib/POKITTO_CORE/PALETTES/palDB16.o
OBJECTS += build/PokittoLib/POKITTO_CORE/PALETTES/palDefault.o
OBJECTS += build/PokittoLib/POKITTO_CORE/PALETTES/palGameboy.o
OBJECTS += build/PokittoLib/POKITTO_CORE/PALETTES/palMagma.o
OBJECTS += build/PokittoLib/POKITTO_CORE/PALETTES/palMono.o
OBJECTS += build/PokittoLib/POKITTO_CORE/PALETTES/palPico.o
OBJECTS += build/PokittoLib/POKITTO_CORE/PALETTES/palRainbow.o
OBJECTS += build/PokittoLib/POKITTO_CORE/PALETTES/palZXSpec.o
OBJECTS += build/PokittoLib/POKITTO_CORE/PokittoBacklight.o
OBJECTS += build/PokittoLib/POKITTO_CORE/PokittoBattery.o
OBJECTS += build/PokittoLib/POKITTO_CORE/PokittoButtons.o
OBJECTS += build/PokittoLib/POKITTO_CORE/PokittoConsole.o
OBJECTS += build/PokittoLib/POKITTO_CORE/PokittoCookie.o
OBJECTS += build/PokittoLib/POKITTO_CORE/PokittoCore.o
OBJECTS += build/PokittoLib/POKITTO_CORE/PokittoDisk.o
OBJECTS += build/PokittoLib/POKITTO_CORE/PokittoDisplay.o
OBJECTS += build/PokittoLib/POKITTO_CORE/PokittoItoa.o
OBJECTS += build/PokittoLib/POKITTO_CORE/PokittoLogos.o
OBJECTS += build/PokittoLib/POKITTO_CORE/PokittoPalette.o
OBJECTS += build/PokittoLib/POKITTO_CORE/PokittoPrintf.o
OBJECTS += build/PokittoLib/POKITTO_CORE/PokittoSound.o
OBJECTS += build/PokittoLib/POKITTO_HW/HWButtons.o
OBJECTS += build/PokittoLib/POKITTO_HW/HWLCD.o
OBJECTS += build/PokittoLib/POKITTO_HW/HWSound.o
OBJECTS += build/PokittoLib/POKITTO_HW/PokittoClock.o
OBJECTS += build/PokittoLib/POKITTO_HW/PokittoHW.o
OBJECTS += build/PokittoLib/POKITTO_HW/Pokitto_extport.o
OBJECTS += build/PokittoLib/POKITTO_HW/SoftwareI2C.o
OBJECTS += build/PokittoLib/POKITTO_HW/clock_11u6x.o
OBJECTS += build/PokittoLib/POKITTO_HW/dma_11u6x.o
OBJECTS += build/PokittoLib/POKITTO_HW/iap.o
OBJECTS += build/PokittoLib/POKITTO_HW/timer_11u6x.o
OBJECTS += build/PokittoLib/POKITTO_LIBS/ImageFormat/BmpImage.o
OBJECTS += build/PokittoLib/POKITTO_LIBS/Synth/Synth.o
OBJECTS += build/PokittoLib/POKITTO_LIBS/Synth/Synth_envfuncs.o
OBJECTS += build/PokittoLib/POKITTO_LIBS/Synth/Synth_helpers.o
OBJECTS += build/PokittoLib/POKITTO_LIBS/Synth/Synth_mixfuncs.o
OBJECTS += build/PokittoLib/POKITTO_LIBS/Synth/Synth_oscfuncs.o
OBJECTS += build/PokittoLib/POKITTO_LIBS/Synth/Synth_songfuncs.o
OBJECTS += build/PokittoLib/POKITTO_LIBS/Synth/Synth_wavefuncs.o
OBJECTS += build/PokittoLib/POKITTO_LIBS/SDFileSystem/CRC16.o
OBJECTS += build/PokittoLib/POKITTO_LIBS/SDFileSystem/CRC7.o
OBJECTS += build/PokittoLib/POKITTO_LIBS/SDFileSystem/SDFileSystem.o
OBJECTS += build/PokittoLib/POKITTO_LIBS/SDFileSystem/FATFileSystem/FATDirHandle.o
OBJECTS += build/PokittoLib/POKITTO_LIBS/SDFileSystem/FATFileSystem/FATFileHandle.o
OBJECTS += build/PokittoLib/POKITTO_LIBS/SDFileSystem/FATFileSystem/FATFileSystem.o
OBJECTS += build/PokittoLib/POKITTO_LIBS/SDFileSystem/FATFileSystem/ChaN/ccsbcs.o
OBJECTS += build/PokittoLib/POKITTO_LIBS/SDFileSystem/FATFileSystem/ChaN/diskio.o
OBJECTS += build/PokittoLib/POKITTO_LIBS/SDFileSystem/FATFileSystem/ChaN/ff.o
OBJECTS += build/PokittoLib/POKITTO_XTERNALS/Arduino/delay.o
OBJECTS += build/PokittoLib/libpff/mmc.o
OBJECTS += build/PokittoLib/libpff/pff.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/BusIn.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/BusInOut.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/BusOut.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/CAN.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/CallChain.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/Ethernet.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/FileBase.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/FileLike.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/FilePath.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/FileSystemLike.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/I2C.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/I2CSlave.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/InterruptIn.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/InterruptManager.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/LocalFileSystem.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/RawSerial.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/SPI.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/SPISlave.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/Serial.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/SerialBase.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/Stream.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/Ticker.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/Timeout.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/Timer.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/TimerEvent.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/assert.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/board.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/error.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/gpio.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/lp_ticker_api.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/mbed_interface.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/pinmap_common.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/retarget.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/rtc_time.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/semihost_api.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/ticker_api.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/us_ticker_api.o
OBJECTS += build/PokittoLib/mbed-pokitto/common/wait_api.o
OBJECTS += build/PokittoLib/mbed-pokitto/targets/cmsis/TARGET_NXP/TARGET_LPC11U6X/TOOLCHAIN_GCC_ARM/TARGET_LPC11U68/startup_LPC11U68.o
OBJECTS += build/PokittoLib/mbed-pokitto/targets/cmsis/TARGET_NXP/TARGET_LPC11U6X/cmsis_nvic.o
OBJECTS += build/PokittoLib/mbed-pokitto/targets/cmsis/TARGET_NXP/TARGET_LPC11U6X/system_LPC11U6x.o
OBJECTS += build/PokittoLib/mbed-pokitto/targets/hal/TARGET_NXP/TARGET_LPC11U6X/analogin_api.o
OBJECTS += build/PokittoLib/mbed-pokitto/targets/hal/TARGET_NXP/TARGET_LPC11U6X/gpio_api.o
OBJECTS += build/PokittoLib/mbed-pokitto/targets/hal/TARGET_NXP/TARGET_LPC11U6X/gpio_irq_api.o
OBJECTS += build/PokittoLib/mbed-pokitto/targets/hal/TARGET_NXP/TARGET_LPC11U6X/i2c_api.o
OBJECTS += build/PokittoLib/mbed-pokitto/targets/hal/TARGET_NXP/TARGET_LPC11U6X/pinmap.o
OBJECTS += build/PokittoLib/mbed-pokitto/targets/hal/TARGET_NXP/TARGET_LPC11U6X/pwmout_api.o
OBJECTS += build/PokittoLib/mbed-pokitto/targets/hal/TARGET_NXP/TARGET_LPC11U6X/rtc_api.o
OBJECTS += build/PokittoLib/mbed-pokitto/targets/hal/TARGET_NXP/TARGET_LPC11U6X/serial_api.o
OBJECTS += build/PokittoLib/mbed-pokitto/targets/hal/TARGET_NXP/TARGET_LPC11U6X/sleep.o
OBJECTS += build/PokittoLib/mbed-pokitto/targets/hal/TARGET_NXP/TARGET_LPC11U6X/spi_api.o
OBJECTS += build/PokittoLib/mbed-pokitto/targets/hal/TARGET_NXP/TARGET_LPC11U6X/us_ticker.o

#$(error $(OBJECTS))

INCLUDE_PATHS += -I./.
INCLUDE_PATHS += -I./PokittoLib
INCLUDE_PATHS += -I./PokittoLib/POKITTO_CORE
INCLUDE_PATHS += -I./PokittoLib/POKITTO_CORE/FONTS
INCLUDE_PATHS += -I./PokittoLib/POKITTO_CORE/PALETTES
INCLUDE_PATHS += -I./PokittoLib/POKITTO_HW
INCLUDE_PATHS += -I./PokittoLib/POKITTO_LIBS
INCLUDE_PATHS += -I./PokittoLib/POKITTO_LIBS/FileIO
INCLUDE_PATHS += -I./PokittoLib/POKITTO_LIBS/FixMath
INCLUDE_PATHS += -I./PokittoLib/POKITTO_LIBS/ImageFormat
INCLUDE_PATHS += -I./PokittoLib/POKITTO_LIBS/JoyHat
INCLUDE_PATHS += -I./PokittoLib/POKITTO_LIBS/MicroPython
INCLUDE_PATHS += -I./PokittoLib/POKITTO_LIBS/Physics
INCLUDE_PATHS += -I./PokittoLib/POKITTO_LIBS/SDFileSystem
INCLUDE_PATHS += -I./PokittoLib/POKITTO_LIBS/SDFileSystem/FATFileSystem
INCLUDE_PATHS += -I./PokittoLib/POKITTO_LIBS/SDFileSystem/FATFileSystem/ChaN
INCLUDE_PATHS += -I./PokittoLib/POKITTO_LIBS/Synth
INCLUDE_PATHS += -I./PokittoLib/POKITTO_LIBS/Tilemap
INCLUDE_PATHS += -I./PokittoLib/POKITTO_LIBS/USBDevice
INCLUDE_PATHS += -I./PokittoLib/POKITTO_XTERNALS
INCLUDE_PATHS += -I./PokittoLib/POKITTO_XTERNALS/Arduino
INCLUDE_PATHS += -I./PokittoLib/libpff
INCLUDE_PATHS += -I./PokittoLib/mbed-pokitto
INCLUDE_PATHS += -I./PokittoLib/mbed-pokitto/api
INCLUDE_PATHS += -I./PokittoLib/mbed-pokitto/common
INCLUDE_PATHS += -I./PokittoLib/mbed-pokitto/hal
INCLUDE_PATHS += -I./PokittoLib/mbed-pokitto/targets
INCLUDE_PATHS += -I./PokittoLib/mbed-pokitto/targets/cmsis
INCLUDE_PATHS += -I./PokittoLib/mbed-pokitto/targets/cmsis/TARGET_NXP
INCLUDE_PATHS += -I./PokittoLib/mbed-pokitto/targets/cmsis/TARGET_NXP/TARGET_LPC11U6X
INCLUDE_PATHS += -I./PokittoLib/mbed-pokitto/targets/cmsis/TARGET_NXP/TARGET_LPC11U6X/TOOLCHAIN_GCC_ARM
INCLUDE_PATHS += -I./PokittoLib/mbed-pokitto/targets/cmsis/TARGET_NXP/TARGET_LPC11U6X/TOOLCHAIN_GCC_ARM/TARGET_LPC11U68
INCLUDE_PATHS += -I./PokittoLib/mbed-pokitto/targets/cmsis/TOOLCHAIN_GCC
INCLUDE_PATHS += -I./PokittoLib/mbed-pokitto/targets/hal
INCLUDE_PATHS += -I./PokittoLib/mbed-pokitto/targets/hal/TARGET_NXP
INCLUDE_PATHS += -I./PokittoLib/mbed-pokitto/targets/hal/TARGET_NXP/TARGET_LPC11U6X

LIBRARY_PATHS :=
LIBRARIES :=
LINKER_SCRIPT ?= ./PokittoLib/mbed-pokitto/targets/cmsis/TARGET_NXP/TARGET_LPC11U6X/TOOLCHAIN_GCC_ARM/TARGET_LPC11U68/LPC11U68.ld

# Objects and Paths
###############################################################################
# Tools and Flags

AS      = '../gtc/arm-none-eabi-gcc' '-x' 'assembler-with-cpp' '-c' '-Wall' '-Wextra' '-Wno-unused-parameter' '-Wno-missing-field-initializers' '-fmessage-length=0' '-fno-exceptions' '-fno-builtin' '-ffunction-sections' '-fdata-sections' '-funsigned-char' '-MMD' '-fno-delete-null-pointer-checks' '-fomit-frame-pointer' '-O3' '-g1' '-DMBED_RTOS_SINGLE_THREAD' '-mcpu=cortex-m0plus' '-mthumb'
CC      = '../gtc/arm-none-eabi-gcc' '-std=gnu89' '-c' '-Wall' '-Wextra' '-Wno-unused-parameter' '-Wno-missing-field-initializers' '-fmessage-length=0' '-fno-exceptions' '-fno-builtin' '-ffunction-sections' '-fdata-sections' '-funsigned-char' '-MMD' '-fno-delete-null-pointer-checks' '-fomit-frame-pointer' '-O3' '-g1' '-DMBED_RTOS_SINGLE_THREAD' '-mcpu=cortex-m0plus' '-mthumb'
CPP     = '../gtc/arm-none-eabi-g++' '-std=c++11' '-fno-rtti' '-Wvla' '-c' '-Wall' '-Wextra' '-Wno-unused-parameter' '-Wno-missing-field-initializers' '-fmessage-length=0' '-fno-exceptions' '-fno-builtin' '-ffunction-sections' '-fdata-sections' '-funsigned-char' '-MMD' '-fno-delete-null-pointer-checks' '-fomit-frame-pointer' '-O3' '-g1' '-DMBED_RTOS_SINGLE_THREAD' '-mcpu=cortex-m0plus' '-mthumb'
LD      = '../gtc/arm-none-eabi-gcc'
ELF2BIN = '../gtc/arm-none-eabi-objcopy'
PREPROC = '../gtc/arm-none-eabi-cpp' '-E' '-P' '-Wl,--gc-sections' '-Wl,--wrap,main' '-Wl,--wrap,_malloc_r' '-Wl,--wrap,_free_r' '-Wl,--wrap,_realloc_r' '-Wl,--wrap,_memalign_r' '-Wl,--wrap,_calloc_r' '-Wl,--wrap,exit' '-Wl,--wrap,atexit' '-Wl,-n' '--specs=nano.specs' '-mcpu=cortex-m0plus' '-mthumb'


C_FLAGS += -std=gnu89
C_FLAGS += -DTARGET_LPC11U68
C_FLAGS += -D__MBED__=1
C_FLAGS += -DDEVICE_I2CSLAVE=1
C_FLAGS += -DTARGET_LIKE_MBED
C_FLAGS += -DTARGET_NXP
C_FLAGS += -D__MBED_CMSIS_RTOS_CM
C_FLAGS += -DDEVICE_RTC=1
C_FLAGS += -DTOOLCHAIN_object
C_FLAGS += -D__CMSIS_RTOS
C_FLAGS += -DTOOLCHAIN_GCC
C_FLAGS += -DTARGET_CORTEX_M
C_FLAGS += -DTARGET_M0P
C_FLAGS += -DTARGET_UVISOR_UNSUPPORTED
C_FLAGS += -DMBED_BUILD_TIMESTAMP=1526086019.89
C_FLAGS += -DDEVICE_SERIAL=1
C_FLAGS += -DDEVICE_INTERRUPTIN=1
C_FLAGS += -DTARGET_LPCTarget
C_FLAGS += -DTARGET_CORTEX
C_FLAGS += -DDEVICE_I2C=1
C_FLAGS += -D__CORTEX_M0PLUS
C_FLAGS += -DTARGET_FF_ARDUINO
C_FLAGS += -DTARGET_RELEASE
C_FLAGS += -DARM_MATH_CM0PLUS
C_FLAGS += -DTARGET_LPC11U6X
C_FLAGS += -DDEVICE_SLEEP=1
C_FLAGS += -DTOOLCHAIN_GCC_ARM
C_FLAGS += -DDEVICE_SPI=1
C_FLAGS += -DDEVICE_ANALOGIN=1
C_FLAGS += -DDEVICE_PWMOUT=1
C_FLAGS += -DTARGET_LIKE_CORTEX_M0
C_FLAGS += -include
C_FLAGS += mbed_config.h
C_FLAGS += '-DEMBEDROM="tetris.c"'

CXX_FLAGS += -std=c++11
CXX_FLAGS += -fno-rtti
CXX_FLAGS += -Wvla
CXX_FLAGS += -DTARGET_LPC11U68
CXX_FLAGS += -D__MBED__=1
CXX_FLAGS += -DDEVICE_I2CSLAVE=1
CXX_FLAGS += -DTARGET_LIKE_MBED
CXX_FLAGS += -DTARGET_NXP
CXX_FLAGS += -D__MBED_CMSIS_RTOS_CM
CXX_FLAGS += -DDEVICE_RTC=1
CXX_FLAGS += -DTOOLCHAIN_object
CXX_FLAGS += -D__CMSIS_RTOS
CXX_FLAGS += -DTOOLCHAIN_GCC
CXX_FLAGS += -DTARGET_CORTEX_M
CXX_FLAGS += -DTARGET_M0P
CXX_FLAGS += -DTARGET_UVISOR_UNSUPPORTED
CXX_FLAGS += -DMBED_BUILD_TIMESTAMP=1526086019.89
CXX_FLAGS += -DDEVICE_SERIAL=1
CXX_FLAGS += -DDEVICE_INTERRUPTIN=1
CXX_FLAGS += -DTARGET_LPCTarget
CXX_FLAGS += -DTARGET_CORTEX
CXX_FLAGS += -DDEVICE_I2C=1
CXX_FLAGS += -D__CORTEX_M0PLUS
CXX_FLAGS += -DTARGET_FF_ARDUINO
CXX_FLAGS += -DTARGET_RELEASE
CXX_FLAGS += -DARM_MATH_CM0PLUS
CXX_FLAGS += -DTARGET_LPC11U6X
CXX_FLAGS += -DDEVICE_SLEEP=1
CXX_FLAGS += -DTOOLCHAIN_GCC_ARM
CXX_FLAGS += -DDEVICE_SPI=1
CXX_FLAGS += -DDEVICE_ANALOGIN=1
CXX_FLAGS += -DDEVICE_PWMOUT=1
CXX_FLAGS += -DTARGET_LIKE_CORTEX_M0
CXX_FLAGS += -include
CXX_FLAGS += mbed_config.h

ASM_FLAGS += -x
ASM_FLAGS += assembler-with-cpp
ASM_FLAGS += -D__CMSIS_RTOS
ASM_FLAGS += -D__MBED_CMSIS_RTOS_CM
ASM_FLAGS += -D__CORTEX_M0PLUS
ASM_FLAGS += -DARM_MATH_CM0PLUS
ASM_FLAGS += -I./.
ASM_FLAGS += -I./PokittoLib
ASM_FLAGS += -I./PokittoLib/POKITTO_CORE
ASM_FLAGS += -I./PokittoLib/POKITTO_CORE/FONTS
ASM_FLAGS += -I./PokittoLib/POKITTO_CORE/PALETTES
ASM_FLAGS += -I./PokittoLib/POKITTO_HW
ASM_FLAGS += -I./PokittoLib/POKITTO_LIBS
ASM_FLAGS += -I./PokittoLib/POKITTO_LIBS/FileIO
ASM_FLAGS += -I./PokittoLib/POKITTO_LIBS/FixMath
ASM_FLAGS += -I./PokittoLib/POKITTO_LIBS/ImageFormat
ASM_FLAGS += -I./PokittoLib/POKITTO_LIBS/JoyHat
ASM_FLAGS += -I./PokittoLib/POKITTO_LIBS/MicroPython
ASM_FLAGS += -I./PokittoLib/POKITTO_LIBS/Physics
ASM_FLAGS += -I./PokittoLib/POKITTO_LIBS/SDFileSystem
ASM_FLAGS += -I./PokittoLib/POKITTO_LIBS/SDFileSystem/FATFileSystem
ASM_FLAGS += -I./PokittoLib/POKITTO_LIBS/SDFileSystem/FATFileSystem/ChaN
ASM_FLAGS += -I./PokittoLib/POKITTO_LIBS/Synth
ASM_FLAGS += -I./PokittoLib/POKITTO_LIBS/Tilemap
ASM_FLAGS += -I./PokittoLib/POKITTO_LIBS/USBDevice
ASM_FLAGS += -I./PokittoLib/POKITTO_XTERNALS
ASM_FLAGS += -I./PokittoLib/POKITTO_XTERNALS/Arduino
ASM_FLAGS += -I./PokittoLib/libpff
ASM_FLAGS += -I./PokittoLib/mbed-pokitto
ASM_FLAGS += -I./PokittoLib/mbed-pokitto/api
ASM_FLAGS += -I./PokittoLib/mbed-pokitto/common
ASM_FLAGS += -I./PokittoLib/mbed-pokitto/hal
ASM_FLAGS += -I./PokittoLib/mbed-pokitto/targets
ASM_FLAGS += -I./PokittoLib/mbed-pokitto/targets/cmsis
ASM_FLAGS += -I./PokittoLib/mbed-pokitto/targets/cmsis/TARGET_NXP
ASM_FLAGS += -I./PokittoLib/mbed-pokitto/targets/cmsis/TARGET_NXP/TARGET_LPC11U6X
ASM_FLAGS += -I./PokittoLib/mbed-pokitto/targets/cmsis/TARGET_NXP/TARGET_LPC11U6X/TOOLCHAIN_GCC_ARM
ASM_FLAGS += -I./PokittoLib/mbed-pokitto/targets/cmsis/TARGET_NXP/TARGET_LPC11U6X/TOOLCHAIN_GCC_ARM/TARGET_LPC11U68
ASM_FLAGS += -I./PokittoLib/mbed-pokitto/targets/cmsis/TOOLCHAIN_GCC
ASM_FLAGS += -I./PokittoLib/mbed-pokitto/targets/hal
ASM_FLAGS += -I./PokittoLib/mbed-pokitto/targets/hal/TARGET_NXP
ASM_FLAGS += -I./PokittoLib/mbed-pokitto/targets/hal/TARGET_NXP/TARGET_LPC11U6X


LD_FLAGS :=-Wl,--gc-sections -Wl,--wrap,main -Wl,--wrap,_memalign_r -Wl,-n --specs=nano.specs -mcpu=cortex-m0plus -mthumb 
LD_SYS_LIBS :=-Wl,--start-group -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys  -Wl,--end-group

# Tools and Flags
###############################################################################
# Rules

.PHONY: all lst size


all: $(BPROJECT).bin $(BPROJECT).hex size
	+@$(call MAKEDIR,$(OBJDIR))


.s.o:
	+@$(call MAKEDIR,$(dir $@))
	+@echo "Assemble: $(notdir $<)"
	@$(AS) -c $(ASM_FLAGS) -o $@ $<


.S.o:
	+@$(call MAKEDIR,$(dir $@))
	+@echo "Assemble: $(notdir $<)"
	@$(AS) -c $(ASM_FLAGS) -o $@ $<

build/%.o : %.c
	+@$(call MAKEDIR,$(dir $@))
	+@echo "Compile: $(notdir $<)"
	@$(CC) $(C_FLAGS) $(INCLUDE_PATHS) -o $@ $<

build/%.o : %.cpp
	+@$(call MAKEDIR,$(dir $@))
	+@echo "Compile: $(notdir $<)"
	@$(CPP) $(CXX_FLAGS) $(INCLUDE_PATHS) -o $@ $<


$(BPROJECT).link_script.ld: $(LINKER_SCRIPT)
	@$(PREPROC) $< -o $@



$(BPROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) $(BPROJECT).link_script.ld 
	+@echo "link: $(notdir $@)"
	@$(LD) $(LD_FLAGS) -T $(filter-out %.o, $^) $(LIBRARY_PATHS) --output $@ $(filter %.o, $^) $(LIBRARIES) $(LD_SYS_LIBS)


$(BPROJECT).bin: $(BPROJECT).elf
	$(ELF2BIN) -O binary $< $@
	+@echo "===== bin file ready to flash: $(OBJDIR)/$@ =====" 

$(BPROJECT).hex: $(BPROJECT).elf
	$(ELF2BIN) -O ihex $< $@

size: $(BPROJECT).elf
	../gtc/arm-none-eabi-size $(BPROJECT).elf | ../tools/size

# Rules
###############################################################################
# Dependencies

DEPS = $(OBJECTS:.o=.d) $(SYS_OBJECTS:.o=.d)
-include $(DEPS)
# endif

# Dependencies
###############################################################################

clean :
	$(call RM,$(OBJDIR))

I noticed however that the original was using -std=gnu++98 and had to change it to -std=c++11 in order to compile Xplorito. I also added a section at the top to enable overclocking by calling make with OC=on. Leaving -std=gnu++98 still gave the same results for the SDFileIO example though.

Hopefully this will provide some additional information on my exact setup to narrow it down. My windows machine hasn’t worked well for a while now so it’s hard to test it using some of the available IDE options and as I mentioned mbed is not liking their own SDFileSystem library.

An additional test I did was the pre-compiled binaries and my compiled binaries in the emulator using the -I argument and passing it an img file. The img file is a direct rip of the sd card that came with my pokitto and it’s behaving the same (ie. pre-compiled binary works fine, my compiled binaries don’t).

At the moment it seems like this might be a compile platform issue, but there’s been some recent changes to the PokittoLib so it’s hard to be sure. In the morning I’ll go through the commit history and get the version of the PokittoLib that was in existence when v0.1.1 of Xploritto was released ( 24-06-2019) and see if that changes anything. If it does I’ll do a diff comparison to isolate what changes were made and see which one is causing it.

In the meantime if someone else can take the latest version of both from github and try compiling it under different environments and see if they get the same results that would also help narrow it down.

1 Like

It has been a long time since I’ve tested mbed, but I vaguely remember there was more than one SDFileSystem library there, one of which was buggy/discontinued/outdated.

One thing you can try is getting the PokittoLib from github and overwriting the one you have. It should come with the correct library.

What OS are you on, btw? If it’s Linux/OSX, FemtoIDE is available for it and also comes with the correct SDFS.

Compiling Xploritto with the FemtoIDE works better but it crashes when it tries to read a POP file. If I try and debug it I get

Program received signal SIGTRAP, Trace/breakpoint trap.
0x000156de in _free_r ()

Which fails at the following line:

GDB: #8 SDBrowse::draw (this=0x10005e98) at /home/justin/Downloads/FemtoIDE/projects/Xploritto/SDBrowse.cpp:472
472	Pop::open(f);

This crash happens in the emulator causing a segfault when not run in debug mode and freezes when run on hardware.

The SDFileIO example still doesn’t work, but I just tried the pre-compiled version in the build folder and it also doesn’t work. If I remove the file creation part of SDFileIO and simply have it read a file that already exists then the SDFileSystem read works but the PFFS doesn’t. I just discovered that the PFFS only allows filenames in the 8.3 format and can now read using it. Still doesn’t explain the weird crash when building Xploritto from source, and should still be looked into, but it looks like my issues with the sd card has to do with the CLI setup.

Since it looks like the FemtoIDE allows you to use an external editor I think I will switch to using it instead. This will save me some headache in the future. Plus it has built-in debugging available and it took me about 20 seconds to figure out how to launch the emulator with an SD card image. Since I’m on linux I have the img mounted as a loop device allowing me to modify it and then re-launch the emulator. Unfortunately the emulator doesn’t support updating the img file with any changes made by the running program, but maybe someday.

1 Like

When i try to build Xporitto with latest femtoIDE and latest PokittoLib, i had the same problems as you.
(loading files in Xploritto cause a SIGTRAP crash)
Xploritto version 0.1.1 was origanally built using EmBitz, before femtoIDE was a thing.
When i compare the build flags i notice that i was compiling it with -std=c++11 .
So when i change to -std=c++11 from -std=c++14 in project.json everything work fine.
Maybe something in SDFilesSystem is not compatible with C++ 14 :thinking:.

Edit:
Here is my working project
Xploritto.zip (194.8 KB)

1 Like

@FManga , if this is true we have a potential showstopper!

Showstopper… or an excuse to take the Cleanup even further? :thinking:

2 Likes

I am not sure I am totally enthusiastic about losing mbed connection completely and/or rewriting things like SDFileSystem just for the sake of C++11->C++17

Not for the sake of C++17, but for the sake of having a single filesystem library that doesn’t have the limitations of PFFS, the memory leaks of SDFS, or the confusion of having both.

6 Likes

Well, we’ve seen miracles here before so I have no doubt it can be done

3 Likes

I’ve still got the tilemap thing to finish, then I need to update micropython. After that I’ll give the filesystem situation a look to see if it’s something that can be tackled now or if it would be better to just find out what breaks in C++14.
It is very odd that something breaks when going from 11 to 14 and it suggests the code is relying on undefined behaviour.

1 Like

When compiling with std=c++11 it still crashes the same. However if I launch the emulator through FemtoIDE instead of the command line I get a better message then segfault. Running through with GDB still causes the breakpoint trap at the previously mentioned location.

UNKNOWN OP effe@ PC=1e
Attempt to write to flash (0x204) on PC=0x2236

If @bl_ackrain was able to successfully compile it using std=c++11 but I’m still getting the same results whether I use c++11 or c++14 means there’s something deeper going on with the libs/setup. Looking through the compilation process there’s mostly just a lot of redefinition warnings, although most of the warnings aren’t visible anymore due to scroll limits in FemtoIDE (it only shows the last X output lines, and I don’t see a setting anywhere to change that).

I noticed there’s a lot of redefinition warnings when using both PFFS and SDFileSystem. When doing a library overhaul it would be nice to still get the best of both worlds. That is use SDFileSystem when integrity is important, or when creating new files/folders, but switching to PFFS when streaming large amounts of data in real-time.

1 Like

I’ve been contemplating this for a while but so far most of my time has been spent contemplating an API rather than actually building anything that works.

I’ve only made one prototype API, most of which is hosted here:

(Some of the function names aren’t ideal,
e.g. Filesystem::delete naturally clashes with the delete keyword.)

I was designing it with C++11 in mind though,
with access to C++17 I’d redesign quite a few things,
e.g. make more use of std::optional and std::variant.

Though I think the most important thing is to have an actual File object that self-closes itself upon destruction to prevent memory leaks,
and to perhaps extend that philosophy to other parts of the library.
I.e. don’t expect the user to remember to close and dispose of things (especially if the user is more familiar with GCed languages like Python)

1 Like

This error is unrelated to SDFS and C++17, I get the same thing with C++11. Xploritto is crashing due to running out of memory:
static bool open(const std::string path);
This should be a const std::string& so as to not allocate a copy on the heap.

As for SDFS not creating files, it turned out to be a bug in the emulator. I’m testing a fix and now the following works on both the emulator and hardware:

#include "Pokitto.h"
int main(){
    using PC=Pokitto::Core;
    
    PC::begin();    
    char str[33] = {};
    auto sdfs = new SDFileSystem(P0_9, P0_8, P0_6, P0_7, "sd", NC, SDFileSystem::SWITCH_NONE, 24000000 );
    sdfs->write_validation(false);
    sdfs->crc(false);
    {
        auto f = sdfs->open("x.txt", O_CREAT | O_RDWR );
        f->write("this is a test", 14);
        f->close();
    }
    {
        auto f = sdfs->open("x.txt", O_RDONLY );
        f->read(str, 32);
        f->close();
    }

    printf("%s\n", str);
}
2 Likes

Nice. Just tested it and now it’s working. Also noticed ~13 hours ago a commit to allow dumping the SD image on exit :grin: :+1::+1:

Will definitely need to test this. Been stress testing everything so I know just how far I can push this little guy before starting my long-term project. Part of the tests is seeing how things behave in the emulator vs actual hardware, will continue to provide feedback as I discover things.

Keep up the amazing work.

2 Likes

I second this, amazing is the word!

1 Like

Spoiler! :stuck_out_tongue:

Also added read-only support for img files to the IDE:

3 Likes