Embed ini (#2417)
* replace null device with rusefi ini * comment * warning * stub ramdisk for when we don' thave an image * maybe generate the image with a build * install mtools * fail on error * install deps _before_ we need them * embed a little readme * oops
This commit is contained in:
parent
d71b1184fc
commit
496acd7fc0
|
@ -89,10 +89,16 @@ jobs:
|
|||
- uses: actions/checkout@v1
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: '8'
|
||||
|
||||
- name: Install multilib, mingw, ncftp and mtools
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install gcc-multilib g++-multilib g++-mingw-w64 gcc-mingw-w64 ncftp mtools
|
||||
|
||||
- name: Generate Configs
|
||||
if: ${{ matrix.skip-config != 'yes' }}
|
||||
working-directory: ./firmware/
|
||||
|
@ -137,12 +143,6 @@ jobs:
|
|||
- name: Test Compiler
|
||||
run: arm-none-eabi-gcc -v
|
||||
|
||||
- name: Install multilib, mingw, and ncftp
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install gcc-multilib g++-multilib g++-mingw-w64 gcc-mingw-w64 ncftp
|
||||
|
||||
|
||||
- name: Configs Set FTP variables
|
||||
env:
|
||||
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
|
||||
|
|
|
@ -202,6 +202,7 @@ $(info LDSCRIPT: $(LDSCRIPT))
|
|||
# setting.
|
||||
CSRC = $(ALLCSRC) \
|
||||
$(CHIBIOS)/os/various/syscalls.c \
|
||||
$(CHIBIOS_CONTRIB)/os/various/ramdisk.c \
|
||||
$(TRIGGER_SRC) \
|
||||
$(TRIGGER_DECODERS_SRC) \
|
||||
$(DEV_SRC) \
|
||||
|
|
|
@ -253,6 +253,10 @@
|
|||
#define EFI_FILE_LOGGING TRUE
|
||||
#endif
|
||||
|
||||
#ifndef EFI_EMBED_INI_MSD
|
||||
#define EFI_EMBED_INI_MSD TRUE
|
||||
#endif
|
||||
|
||||
#ifndef EFI_USB_SERIAL
|
||||
#define EFI_USB_SERIAL TRUE
|
||||
#endif
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
# file gen_config_board.sh
|
||||
|
||||
#set -x
|
||||
set -e
|
||||
|
||||
echo "This script reads rusefi_config.txt and produces firmware persistent configuration headers"
|
||||
echo "the storage section of rusefiXXX.ini is updated as well"
|
||||
|
@ -38,4 +38,6 @@ java -DSystemOut.name=gen_config_board \
|
|||
|
||||
[ $? -eq 0 ] || { echo "ERROR generating TunerStudio config for ${BOARDNAME}"; exit 1; }
|
||||
|
||||
./hw_layer/mass_storage/create_ini_image.sh ./tunerstudio/generated/rusefi_${SHORT_BOARDNAME}.ini ./hw_layer/mass_storage/ramdisk_image.h
|
||||
|
||||
exit 0
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
Welcome to rusEFI!
|
||||
|
||||
Unzip rusefi.ini.zip to your PC, and use the extracted
|
||||
ini file with TunerStudio to connect to your ECU.
|
|
@ -1,40 +0,0 @@
|
|||
https://github.com/tegesoft/Chibios-USB-Devices/
|
||||
http://www.chibios.com/forum/viewtopic.php?f=3&t=619
|
||||
|
||||
Mass Storage Device
|
||||
===================
|
||||
|
||||
This driver implements a USB mass storage device. It requires a Chibios block device (e.g mmc_spi or SDC)
|
||||
|
||||
Example usage:
|
||||
--------------
|
||||
```c
|
||||
|
||||
USBMassStorageDriver UMSD1;
|
||||
|
||||
mmcObjectInit(&MMCD1);
|
||||
mmcStart(&MMCD1, &mmccfg);
|
||||
mmcConnect(&MMCD1);
|
||||
|
||||
msdInit(&USBD1, &MMCD1, &UMSD1);
|
||||
```
|
||||
|
||||
Events:
|
||||
--------------
|
||||
```c
|
||||
chEvtRegisterMask(&UMSD1.evt_connected, &listener_connected, 1);
|
||||
chEvtRegisterMask(&UMSD1.evt_ejected, &listener_ejected, 2);
|
||||
|
||||
while(TRUE) {
|
||||
if(chEvtWaitOneTimeout(1, TIME_IMMEDIATE)) {
|
||||
/* drive is now connected */
|
||||
|
||||
/* wait until the drive is ejected */
|
||||
chEvtWaitOne(2);
|
||||
|
||||
/* drive is now ejected. do something */
|
||||
}
|
||||
|
||||
chThdSleepMilliseconds(1000);
|
||||
}
|
||||
```
|
|
@ -0,0 +1,28 @@
|
|||
#!/bin/bash
|
||||
|
||||
# fail on error
|
||||
set -e
|
||||
|
||||
rm -f rusefi.zip ramdisk_image.h
|
||||
|
||||
# copy 100KB of zeroes
|
||||
dd if=/dev/zero of=ramdisk.image bs=1024 count=100
|
||||
|
||||
# create a FAT filesystem inside, name it RUSEFI
|
||||
mkfs.fat ramdisk.image
|
||||
fatlabel ramdisk.image RUSEFI
|
||||
|
||||
# -j option dumps all files in the root of the zip (instead of inside directories)
|
||||
zip -j rusefi.ini.zip $1
|
||||
|
||||
# Put the zip inside the filesystem
|
||||
mcopy -i ramdisk.image rusefi.ini.zip ::
|
||||
# Put a readme text file in there too
|
||||
mcopy -i ramdisk.image hw_layer/mass_storage/README.txt ::
|
||||
|
||||
# write out as a C array, with "static const" tacked on the front
|
||||
xxd -i ramdisk.image \
|
||||
| cat <(echo -n "static const ") - \
|
||||
> $2
|
||||
|
||||
rm ramdisk.image rusefi.ini.zip
|
|
@ -10,6 +10,18 @@
|
|||
|
||||
#include "hal.h"
|
||||
|
||||
#if EFI_EMBED_INI_MSD
|
||||
#include "ramdisk.h"
|
||||
#include "ramdisk_image.h"
|
||||
|
||||
// If the ramdisk image told us not to use it, don't use it.
|
||||
#ifdef RAMDISK_INVALID
|
||||
#undef EFI_EMBED_INI_MSD
|
||||
#define EFI_EMBED_INI_MSD FALSE
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#include <cstring>
|
||||
|
||||
struct NullDevice {
|
||||
|
@ -65,11 +77,34 @@ static const struct BaseBlockDeviceVMT ndVmt = {
|
|||
nd_get_info
|
||||
};
|
||||
|
||||
#if EFI_EMBED_INI_MSD
|
||||
static RamDisk ramdisk;
|
||||
#else
|
||||
// This device is always ready and has no state
|
||||
static NullDevice nd = { &ndVmt, BLK_READY };
|
||||
#endif
|
||||
|
||||
#if HAL_USE_USB_MSD
|
||||
void msdMountNullDevice(USBMassStorageDriver* msdp, USBDriver *usbp, uint8_t* blkbuf, const scsi_inquiry_response_t* inquiry) {
|
||||
// TODO: implement multi-LUN so we can mount the ini image and SD card at the same time
|
||||
|
||||
#if EFI_EMBED_INI_MSD
|
||||
ramdiskObjectInit(&ramdisk);
|
||||
|
||||
constexpr size_t ramdiskSize = sizeof(ramdisk_image);
|
||||
constexpr size_t blockSize = 512;
|
||||
constexpr size_t blockCount = ramdiskSize / blockSize;
|
||||
|
||||
// Ramdisk should be a round number of blocks
|
||||
static_assert(ramdiskSize % blockSize == 0);
|
||||
|
||||
ramdiskStart(&ramdisk, const_cast<uint8_t*>(ramdisk_image), blockSize, blockCount, /*readonly =*/ true);
|
||||
|
||||
msdStart(msdp, usbp, (BaseBlockDevice*)&ramdisk, blkbuf, inquiry, nullptr);
|
||||
|
||||
#else
|
||||
// No embedded ini file, just mount the null device instead
|
||||
msdStart(msdp, usbp, (BaseBlockDevice*)&nd, blkbuf, inquiry, nullptr);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
// This file will be replaced by a ramdisk image containing the corresponding ini
|
||||
// Defining this macro tells the ramdisk to instead mount a null device instead of
|
||||
// the filesystem image, since we don't have one.
|
||||
#define RAMDISK_INVALID
|
Loading…
Reference in New Issue