mirror of
https://github.com/marqs85/ossc
synced 2025-07-29 03:38:14 +03:00
Compare commits
2 Commits
21f8bc5406
...
6198ce7d9e
Author | SHA1 | Date | |
---|---|---|---|
![]() |
6198ce7d9e | ||
![]() |
30d403f157 |
@ -130,7 +130,7 @@ alt_u32 I2C_read(alt_u32 base,alt_u32 last)
|
||||
int I2C_write
|
||||
assumes that any addressing and start
|
||||
has already been done.
|
||||
writes one byte of data from the slave.
|
||||
writes one byte of data from the slave.
|
||||
If last is set the stop bit set.
|
||||
inputs
|
||||
base = the base address of the component
|
||||
@ -182,7 +182,7 @@ alt_u32 I2C_write(alt_u32 base,alt_u8 data, alt_u32 last)
|
||||
|
||||
}
|
||||
|
||||
void SPI_read(alt_u32 base, alt_u8 *rdata, int len)
|
||||
void __attribute__((noinline, flatten, __section__(".text_bram"))) SPI_read(alt_u32 base, alt_u8 *rdata, int len)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -197,7 +197,7 @@ void SPI_read(alt_u32 base, alt_u8 *rdata, int len)
|
||||
}
|
||||
}
|
||||
|
||||
void SPI_write(alt_u32 base, const alt_u8 *wdata, int len)
|
||||
void __attribute__((noinline, flatten, __section__(".text_bram"))) SPI_write(alt_u32 base, const alt_u8 *wdata, int len)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
2
ossc.cof
2
ossc.cof
@ -10,7 +10,7 @@
|
||||
<user_name>Page_0</user_name>
|
||||
<page_flags>1</page_flags>
|
||||
<bit0>
|
||||
<sof_filename>output_files/ossc.sof</sof_filename>
|
||||
<sof_filename>output_files/ossc.sof<compress_bitstream>1</compress_bitstream></sof_filename>
|
||||
</bit0>
|
||||
</sof_data>
|
||||
<hex_block>
|
||||
|
1
ossc.qsf
1
ossc.qsf
@ -258,4 +258,5 @@ set_global_assignment -name SEARCH_PATH rtl
|
||||
set_global_assignment -name SEARCH_PATH software/sys_controller/mem_init/
|
||||
set_global_assignment -name SEARCH_PATH ip/ibex_qsys/rtl_extra
|
||||
set_global_assignment -name VERILOG_MACRO "SYNTHESIS=<None>"
|
||||
set_global_assignment -name STRATIXIII_UPDATE_MODE REMOTE
|
||||
set_instance_assignment -name PARTITION_HIERARCHY root_partition -to | -section_id Top
|
@ -1,8 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CodeLite_Project Name="ossc_sw" InternalType="" Version="11000">
|
||||
<Plugins>
|
||||
<Plugin Name="qmake">
|
||||
<![CDATA[00020001N0005Debug0000000000000001N0007Release000000000000]]>
|
||||
</Plugin>
|
||||
<Plugin Name="CMakePlugin">
|
||||
<![CDATA[[{
|
||||
"name": "Debug",
|
||||
"enabled": false,
|
||||
"buildDirectory": "build",
|
||||
"sourceDirectory": "$(ProjectPath)",
|
||||
"generator": "",
|
||||
"buildType": "",
|
||||
"arguments": [],
|
||||
"parentProject": ""
|
||||
}, {
|
||||
"name": "Release",
|
||||
"enabled": false,
|
||||
"buildDirectory": "build",
|
||||
"sourceDirectory": "$(ProjectPath)",
|
||||
"generator": "",
|
||||
"buildType": "",
|
||||
"arguments": [],
|
||||
"parentProject": ""
|
||||
}]]]>
|
||||
</Plugin>
|
||||
</Plugins>
|
||||
<VirtualDirectory Name="sys_controller">
|
||||
<VirtualDirectory Name="fatfs">
|
||||
<VirtualDirectory Name="source">
|
||||
<File Name="sys_controller/fatfs/source/ffsystem.c"/>
|
||||
<File Name="sys_controller/fatfs/source/ff.h"/>
|
||||
<File Name="sys_controller/fatfs/source/ff.c"/>
|
||||
<File Name="sys_controller/fatfs/source/diskio.h"/>
|
||||
<File Name="sys_controller/fatfs/source/diskio.c"/>
|
||||
<File Name="sys_controller/fatfs/source/ffunicode.c"/>
|
||||
</VirtualDirectory>
|
||||
</VirtualDirectory>
|
||||
<File Name="sys_controller/av_controller.c"/>
|
||||
<VirtualDirectory Name="src">
|
||||
<File Name="sys_controller/src/file.c"/>
|
||||
<File Name="sys_controller/src/sdcard.c"/>
|
||||
<File Name="sys_controller/src/firmware.c"/>
|
||||
<File Name="sys_controller/src/controls.c"/>
|
||||
@ -65,6 +102,7 @@
|
||||
<File Name="sys_controller/ulibSD/spi_io.h"/>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="inc">
|
||||
<File Name="sys_controller/inc/file.h"/>
|
||||
<File Name="sys_controller/inc/firmware.h"/>
|
||||
<File Name="sys_controller/inc/controls.h"/>
|
||||
<File Name="sys_controller/inc/av_controller.h"/>
|
||||
@ -79,35 +117,10 @@
|
||||
<File Name="sys_controller/inc/lcd.h"/>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="config">
|
||||
<File Name="sys_controller/config/ffconf.h"/>
|
||||
<File Name="sys_controller/config/sysconfig.h"/>
|
||||
</VirtualDirectory>
|
||||
</VirtualDirectory>
|
||||
<Plugins>
|
||||
<Plugin Name="qmake">
|
||||
<![CDATA[00020001N0005Debug0000000000000001N0007Release000000000000]]>
|
||||
</Plugin>
|
||||
<Plugin Name="CMakePlugin">
|
||||
<![CDATA[[{
|
||||
"name": "Debug",
|
||||
"enabled": false,
|
||||
"buildDirectory": "build",
|
||||
"sourceDirectory": "$(ProjectPath)",
|
||||
"generator": "",
|
||||
"buildType": "",
|
||||
"arguments": [],
|
||||
"parentProject": ""
|
||||
}, {
|
||||
"name": "Release",
|
||||
"enabled": false,
|
||||
"buildDirectory": "build",
|
||||
"sourceDirectory": "$(ProjectPath)",
|
||||
"generator": "",
|
||||
"buildType": "",
|
||||
"arguments": [],
|
||||
"parentProject": ""
|
||||
}]]]>
|
||||
</Plugin>
|
||||
</Plugins>
|
||||
<Reconciliation>
|
||||
<Regexes/>
|
||||
<Excludepaths/>
|
||||
|
@ -162,6 +162,7 @@ endif
|
||||
C_SRCS += src/sdcard.c
|
||||
C_SRCS += src/fat16_export.c
|
||||
C_SRCS += src/lcd.c
|
||||
C_SRCS += src/file.c
|
||||
C_SRCS += ic_drivers/it6613/EDID.c
|
||||
C_SRCS += ic_drivers/it6613/HDMI_TX.c
|
||||
C_SRCS += ic_drivers/it6613/hdmitx_nios2.c
|
||||
@ -175,6 +176,10 @@ C_SRCS += ic_drivers/st7032/st7032.c
|
||||
C_SRCS += ic_drivers/sh1107/sh1107.c
|
||||
C_SRCS += ulibSD/sd_io.c
|
||||
C_SRCS += ulibSD/spi_io.c
|
||||
C_SRCS += fatfs/source/diskio.c
|
||||
C_SRCS += fatfs/source/ff.c
|
||||
C_SRCS += fatfs/source/ffsystem.c
|
||||
C_SRCS += fatfs/source/ffunicode.c
|
||||
CXX_SRCS :=
|
||||
ASM_SRCS := crt0.boot_E.S
|
||||
|
||||
@ -229,6 +234,7 @@ APP_INCLUDE_DIRS += ic_drivers/st7032
|
||||
APP_INCLUDE_DIRS += ic_drivers/sh1107
|
||||
APP_INCLUDE_DIRS += memory
|
||||
APP_INCLUDE_DIRS += ulibSD
|
||||
APP_INCLUDE_DIRS += fatfs/source
|
||||
APP_LIBRARY_DIRS :=
|
||||
APP_LIBRARY_NAMES :=
|
||||
|
||||
@ -1171,4 +1177,4 @@ rv-reboot:
|
||||
|
||||
rv-ndmreset:
|
||||
jtagconfig
|
||||
system-console -cli --script ../../scripts/rv-ndmreset.tcl
|
||||
system-console -cli --script ../../scripts/rv-ndmreset.tcl
|
||||
|
@ -82,6 +82,11 @@ avinput_t target_input;
|
||||
|
||||
alt_u8 pcm1862_active;
|
||||
|
||||
flash_ctrl_dev flashctrl_dev = {.regs = (volatile gen_flash_if_regs*)INTEL_GENERIC_SERIAL_FLASH_INTERFACE_TOP_0_AVL_CSR_BASE,
|
||||
.flash_size = 0x0200000};
|
||||
|
||||
rem_update_dev rem_reconfig_dev = {.regs = (volatile rem_update_regs*)0x0002a000};
|
||||
|
||||
uint8_t sl_def_iv_x, sl_def_iv_y;
|
||||
|
||||
alt_u32 read_it2(alt_u32 regaddr);
|
||||
@ -951,6 +956,9 @@ int main()
|
||||
// Start system timer
|
||||
alt_timestamp_start();
|
||||
|
||||
// Write-protect flash
|
||||
flash_write_protect(&flashctrl_dev, 1);
|
||||
|
||||
init_stat = init_hw();
|
||||
|
||||
if (init_stat >= 0) {
|
||||
|
296
software/sys_controller/config/ffconf.h
Normal file
296
software/sys_controller/config/ffconf.h
Normal file
@ -0,0 +1,296 @@
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Configurations of FatFs Module
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define FFCONF_DEF 5380 /* Revision ID */
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Function Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define FF_FS_READONLY 0
|
||||
/* This option switches read-only configuration. (0:Read/Write or 1:Read-only)
|
||||
/ Read-only configuration removes writing API functions, f_write(), f_sync(),
|
||||
/ f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate(), f_getfree()
|
||||
/ and optional writing functions as well. */
|
||||
|
||||
|
||||
#define FF_FS_MINIMIZE 0
|
||||
/* This option defines minimization level to remove some basic API functions.
|
||||
/
|
||||
/ 0: Basic functions are fully enabled.
|
||||
/ 1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_truncate() and f_rename()
|
||||
/ are removed.
|
||||
/ 2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1.
|
||||
/ 3: f_lseek() function is removed in addition to 2. */
|
||||
|
||||
|
||||
#define FF_USE_FIND 1
|
||||
/* This option switches filtered directory read functions, f_findfirst() and
|
||||
/ f_findnext(). (0:Disable, 1:Enable 2:Enable with matching altname[] too) */
|
||||
|
||||
|
||||
#define FF_USE_MKFS 0
|
||||
/* This option switches f_mkfs(). (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define FF_USE_FASTSEEK 0
|
||||
/* This option switches fast seek feature. (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define FF_USE_EXPAND 0
|
||||
/* This option switches f_expand(). (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define FF_USE_CHMOD 0
|
||||
/* This option switches attribute control API functions, f_chmod() and f_utime().
|
||||
/ (0:Disable or 1:Enable) Also FF_FS_READONLY needs to be 0 to enable this option. */
|
||||
|
||||
|
||||
#define FF_USE_LABEL 0
|
||||
/* This option switches volume label API functions, f_getlabel() and f_setlabel().
|
||||
/ (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define FF_USE_FORWARD 0
|
||||
/* This option switches f_forward(). (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define FF_USE_STRFUNC 1
|
||||
#define FF_PRINT_LLI 0
|
||||
#define FF_PRINT_FLOAT 0
|
||||
#define FF_STRF_ENCODE 3
|
||||
/* FF_USE_STRFUNC switches the string API functions, f_gets(), f_putc(), f_puts()
|
||||
/ and f_printf().
|
||||
/
|
||||
/ 0: Disable. FF_PRINT_LLI, FF_PRINT_FLOAT and FF_STRF_ENCODE have no effect.
|
||||
/ 1: Enable without LF - CRLF conversion.
|
||||
/ 2: Enable with LF - CRLF conversion.
|
||||
/
|
||||
/ FF_PRINT_LLI = 1 makes f_printf() support long long argument and FF_PRINT_FLOAT = 1/2
|
||||
/ makes f_printf() support floating point argument. These features want C99 or later.
|
||||
/ When FF_LFN_UNICODE >= 1 with LFN enabled, string API functions convert the character
|
||||
/ encoding in it. FF_STRF_ENCODE selects assumption of character encoding ON THE FILE
|
||||
/ to be read/written via those functions.
|
||||
/
|
||||
/ 0: ANSI/OEM in current CP
|
||||
/ 1: Unicode in UTF-16LE
|
||||
/ 2: Unicode in UTF-16BE
|
||||
/ 3: Unicode in UTF-8
|
||||
*/
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Locale and Namespace Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define FF_CODE_PAGE 437
|
||||
/* This option specifies the OEM code page to be used on the target system.
|
||||
/ Incorrect code page setting can cause a file open failure.
|
||||
/
|
||||
/ 437 - U.S.
|
||||
/ 720 - Arabic
|
||||
/ 737 - Greek
|
||||
/ 771 - KBL
|
||||
/ 775 - Baltic
|
||||
/ 850 - Latin 1
|
||||
/ 852 - Latin 2
|
||||
/ 855 - Cyrillic
|
||||
/ 857 - Turkish
|
||||
/ 860 - Portuguese
|
||||
/ 861 - Icelandic
|
||||
/ 862 - Hebrew
|
||||
/ 863 - Canadian French
|
||||
/ 864 - Arabic
|
||||
/ 865 - Nordic
|
||||
/ 866 - Russian
|
||||
/ 869 - Greek 2
|
||||
/ 932 - Japanese (DBCS)
|
||||
/ 936 - Simplified Chinese (DBCS)
|
||||
/ 949 - Korean (DBCS)
|
||||
/ 950 - Traditional Chinese (DBCS)
|
||||
/ 0 - Include all code pages above and configured by f_setcp()
|
||||
*/
|
||||
|
||||
|
||||
#define FF_USE_LFN 1
|
||||
#define FF_MAX_LFN 255
|
||||
/* The FF_USE_LFN switches the support for LFN (long file name).
|
||||
/
|
||||
/ 0: Disable LFN. FF_MAX_LFN has no effect.
|
||||
/ 1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe.
|
||||
/ 2: Enable LFN with dynamic working buffer on the STACK.
|
||||
/ 3: Enable LFN with dynamic working buffer on the HEAP.
|
||||
/
|
||||
/ To enable the LFN, ffunicode.c needs to be added to the project. The LFN feature
|
||||
/ requiers certain internal working buffer occupies (FF_MAX_LFN + 1) * 2 bytes and
|
||||
/ additional (FF_MAX_LFN + 44) / 15 * 32 bytes when exFAT is enabled.
|
||||
/ The FF_MAX_LFN defines size of the working buffer in UTF-16 code unit and it can
|
||||
/ be in range of 12 to 255. It is recommended to be set 255 to fully support the LFN
|
||||
/ specification.
|
||||
/ When use stack for the working buffer, take care on stack overflow. When use heap
|
||||
/ memory for the working buffer, memory management functions, ff_memalloc() and
|
||||
/ ff_memfree() exemplified in ffsystem.c, need to be added to the project. */
|
||||
|
||||
|
||||
#define FF_LFN_UNICODE 0
|
||||
/* This option switches the character encoding on the API when LFN is enabled.
|
||||
/
|
||||
/ 0: ANSI/OEM in current CP (TCHAR = char)
|
||||
/ 1: Unicode in UTF-16 (TCHAR = WCHAR)
|
||||
/ 2: Unicode in UTF-8 (TCHAR = char)
|
||||
/ 3: Unicode in UTF-32 (TCHAR = DWORD)
|
||||
/
|
||||
/ Also behavior of string I/O functions will be affected by this option.
|
||||
/ When LFN is not enabled, this option has no effect. */
|
||||
|
||||
|
||||
#define FF_LFN_BUF 255
|
||||
#define FF_SFN_BUF 12
|
||||
/* This set of options defines size of file name members in the FILINFO structure
|
||||
/ which is used to read out directory items. These values should be suffcient for
|
||||
/ the file names to read. The maximum possible length of the read file name depends
|
||||
/ on character encoding. When LFN is not enabled, these options have no effect. */
|
||||
|
||||
|
||||
#define FF_FS_RPATH 1
|
||||
/* This option configures support for relative path.
|
||||
/
|
||||
/ 0: Disable relative path and remove related API functions.
|
||||
/ 1: Enable relative path. f_chdir() and f_chdrive() are available.
|
||||
/ 2: f_getcwd() is available in addition to 1.
|
||||
*/
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Drive/Volume Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define FF_VOLUMES 1
|
||||
/* Number of volumes (logical drives) to be used. (1-10) */
|
||||
|
||||
|
||||
#define FF_STR_VOLUME_ID 0
|
||||
#define FF_VOLUME_STRS "RAM","NAND","CF","SD","SD2","USB","USB2","USB3"
|
||||
/* FF_STR_VOLUME_ID switches support for volume ID in arbitrary strings.
|
||||
/ When FF_STR_VOLUME_ID is set to 1 or 2, arbitrary strings can be used as drive
|
||||
/ number in the path name. FF_VOLUME_STRS defines the volume ID strings for each
|
||||
/ logical drive. Number of items must not be less than FF_VOLUMES. Valid
|
||||
/ characters for the volume ID strings are A-Z, a-z and 0-9, however, they are
|
||||
/ compared in case-insensitive. If FF_STR_VOLUME_ID >= 1 and FF_VOLUME_STRS is
|
||||
/ not defined, a user defined volume string table is needed as:
|
||||
/
|
||||
/ const char* VolumeStr[FF_VOLUMES] = {"ram","flash","sd","usb",...
|
||||
*/
|
||||
|
||||
|
||||
#define FF_MULTI_PARTITION 0
|
||||
/* This option switches support for multiple volumes on the physical drive.
|
||||
/ By default (0), each logical drive number is bound to the same physical drive
|
||||
/ number and only an FAT volume found on the physical drive will be mounted.
|
||||
/ When this feature is enabled (1), each logical drive number can be bound to
|
||||
/ arbitrary physical drive and partition listed in the VolToPart[]. Also f_fdisk()
|
||||
/ will be available. */
|
||||
|
||||
|
||||
#define FF_MIN_SS 512
|
||||
#define FF_MAX_SS 512
|
||||
/* This set of options configures the range of sector size to be supported. (512,
|
||||
/ 1024, 2048 or 4096) Always set both 512 for most systems, generic memory card and
|
||||
/ harddisk, but a larger value may be required for on-board flash memory and some
|
||||
/ type of optical media. When FF_MAX_SS is larger than FF_MIN_SS, FatFs is
|
||||
/ configured for variable sector size mode and disk_ioctl() needs to implement
|
||||
/ GET_SECTOR_SIZE command. */
|
||||
|
||||
|
||||
#define FF_LBA64 0
|
||||
/* This option switches support for 64-bit LBA. (0:Disable or 1:Enable)
|
||||
/ To enable the 64-bit LBA, also exFAT needs to be enabled. (FF_FS_EXFAT == 1) */
|
||||
|
||||
|
||||
#define FF_MIN_GPT 0x10000000
|
||||
/* Minimum number of sectors to switch GPT as partitioning format in f_mkfs() and
|
||||
/ f_fdisk(). 2^32 sectors maximum. This option has no effect when FF_LBA64 == 0. */
|
||||
|
||||
|
||||
#define FF_USE_TRIM 0
|
||||
/* This option switches support for ATA-TRIM. (0:Disable or 1:Enable)
|
||||
/ To enable this feature, also CTRL_TRIM command should be implemented to
|
||||
/ the disk_ioctl(). */
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ System Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define FF_FS_TINY 0
|
||||
/* This option switches tiny buffer configuration. (0:Normal or 1:Tiny)
|
||||
/ At the tiny configuration, size of file object (FIL) is shrinked FF_MAX_SS bytes.
|
||||
/ Instead of private sector buffer eliminated from the file object, common sector
|
||||
/ buffer in the filesystem object (FATFS) is used for the file data transfer. */
|
||||
|
||||
|
||||
#define FF_FS_EXFAT 1
|
||||
/* This option switches support for exFAT filesystem. (0:Disable or 1:Enable)
|
||||
/ To enable exFAT, also LFN needs to be enabled. (FF_USE_LFN >= 1)
|
||||
/ Note that enabling exFAT discards ANSI C (C89) compatibility. */
|
||||
|
||||
|
||||
#define FF_FS_NORTC 1
|
||||
#define FF_NORTC_MON 11
|
||||
#define FF_NORTC_MDAY 1
|
||||
#define FF_NORTC_YEAR 2024
|
||||
/* The option FF_FS_NORTC switches timestamp feature. If the system does not have
|
||||
/ an RTC or valid timestamp is not needed, set FF_FS_NORTC = 1 to disable the
|
||||
/ timestamp feature. Every object modified by FatFs will have a fixed timestamp
|
||||
/ defined by FF_NORTC_MON, FF_NORTC_MDAY and FF_NORTC_YEAR in local time.
|
||||
/ To enable timestamp function (FF_FS_NORTC = 0), get_fattime() need to be added
|
||||
/ to the project to read current time form real-time clock. FF_NORTC_MON,
|
||||
/ FF_NORTC_MDAY and FF_NORTC_YEAR have no effect.
|
||||
/ These options have no effect in read-only configuration (FF_FS_READONLY = 1). */
|
||||
|
||||
|
||||
#define FF_FS_NOFSINFO 0
|
||||
/* If you need to know correct free space on the FAT32 volume, set bit 0 of this
|
||||
/ option, and f_getfree() at the first time after volume mount will force
|
||||
/ a full FAT scan. Bit 1 controls the use of last allocated cluster number.
|
||||
/
|
||||
/ bit0=0: Use free cluster count in the FSINFO if available.
|
||||
/ bit0=1: Do not trust free cluster count in the FSINFO.
|
||||
/ bit1=0: Use last allocated cluster number in the FSINFO if available.
|
||||
/ bit1=1: Do not trust last allocated cluster number in the FSINFO.
|
||||
*/
|
||||
|
||||
|
||||
#define FF_FS_LOCK 0
|
||||
/* The option FF_FS_LOCK switches file lock function to control duplicated file open
|
||||
/ and illegal operation to open objects. This option must be 0 when FF_FS_READONLY
|
||||
/ is 1.
|
||||
/
|
||||
/ 0: Disable file lock function. To avoid volume corruption, application program
|
||||
/ should avoid illegal open, remove and rename to the open objects.
|
||||
/ >0: Enable file lock function. The value defines how many files/sub-directories
|
||||
/ can be opened simultaneously under file lock control. Note that the file
|
||||
/ lock control is independent of re-entrancy. */
|
||||
|
||||
|
||||
#define FF_FS_REENTRANT 0
|
||||
#define FF_FS_TIMEOUT 1000
|
||||
/* The option FF_FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs
|
||||
/ module itself. Note that regardless of this option, file access to different
|
||||
/ volume is always re-entrant and volume control functions, f_mount(), f_mkfs()
|
||||
/ and f_fdisk(), are always not re-entrant. Only file/directory access to
|
||||
/ the same volume is under control of this featuer.
|
||||
/
|
||||
/ 0: Disable re-entrancy. FF_FS_TIMEOUT have no effect.
|
||||
/ 1: Enable re-entrancy. Also user provided synchronization handlers,
|
||||
/ ff_mutex_create(), ff_mutex_delete(), ff_mutex_take() and ff_mutex_give(),
|
||||
/ must be added to the project. Samples are available in ffsystem.c.
|
||||
/
|
||||
/ The FF_FS_TIMEOUT defines timeout period in unit of O/S time tick.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*--- End of configuration options ---*/
|
377
software/sys_controller/fatfs/source/00history.txt
Normal file
377
software/sys_controller/fatfs/source/00history.txt
Normal file
@ -0,0 +1,377 @@
|
||||
----------------------------------------------------------------------------
|
||||
Revision history of FatFs module
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
R0.00 (February 26, 2006)
|
||||
|
||||
Prototype.
|
||||
|
||||
|
||||
|
||||
R0.01 (April 29, 2006)
|
||||
|
||||
The first release.
|
||||
|
||||
|
||||
|
||||
R0.02 (June 01, 2006)
|
||||
|
||||
Added FAT12 support.
|
||||
Removed unbuffered mode.
|
||||
Fixed a problem on small (<32M) partition.
|
||||
|
||||
|
||||
|
||||
R0.02a (June 10, 2006)
|
||||
|
||||
Added a configuration option (_FS_MINIMUM).
|
||||
|
||||
|
||||
|
||||
R0.03 (September 22, 2006)
|
||||
|
||||
Added f_rename().
|
||||
Changed option _FS_MINIMUM to _FS_MINIMIZE.
|
||||
|
||||
|
||||
|
||||
R0.03a (December 11, 2006)
|
||||
|
||||
Improved cluster scan algorithm to write files fast.
|
||||
Fixed f_mkdir() creates incorrect directory on FAT32.
|
||||
|
||||
|
||||
|
||||
R0.04 (February 04, 2007)
|
||||
|
||||
Added f_mkfs().
|
||||
Supported multiple drive system.
|
||||
Changed some interfaces for multiple drive system.
|
||||
Changed f_mountdrv() to f_mount().
|
||||
|
||||
|
||||
|
||||
R0.04a (April 01, 2007)
|
||||
|
||||
Supported multiple partitions on a physical drive.
|
||||
Added a capability of extending file size to f_lseek().
|
||||
Added minimization level 3.
|
||||
Fixed an endian sensitive code in f_mkfs().
|
||||
|
||||
|
||||
|
||||
R0.04b (May 05, 2007)
|
||||
|
||||
Added a configuration option _USE_NTFLAG.
|
||||
Added FSINFO support.
|
||||
Fixed DBCS name can result FR_INVALID_NAME.
|
||||
Fixed short seek (<= csize) collapses the file object.
|
||||
|
||||
|
||||
|
||||
R0.05 (August 25, 2007)
|
||||
|
||||
Changed arguments of f_read(), f_write() and f_mkfs().
|
||||
Fixed f_mkfs() on FAT32 creates incorrect FSINFO.
|
||||
Fixed f_mkdir() on FAT32 creates incorrect directory.
|
||||
|
||||
|
||||
|
||||
R0.05a (February 03, 2008)
|
||||
|
||||
Added f_truncate() and f_utime().
|
||||
Fixed off by one error at FAT sub-type determination.
|
||||
Fixed btr in f_read() can be mistruncated.
|
||||
Fixed cached sector is not flushed when create and close without write.
|
||||
|
||||
|
||||
|
||||
R0.06 (April 01, 2008)
|
||||
|
||||
Added fputc(), fputs(), fprintf() and fgets().
|
||||
Improved performance of f_lseek() on moving to the same or following cluster.
|
||||
|
||||
|
||||
|
||||
R0.07 (April 01, 2009)
|
||||
|
||||
Merged Tiny-FatFs as a configuration option. (_FS_TINY)
|
||||
Added long file name feature. (_USE_LFN)
|
||||
Added multiple code page feature. (_CODE_PAGE)
|
||||
Added re-entrancy for multitask operation. (_FS_REENTRANT)
|
||||
Added auto cluster size selection to f_mkfs().
|
||||
Added rewind option to f_readdir().
|
||||
Changed result code of critical errors.
|
||||
Renamed string functions to avoid name collision.
|
||||
|
||||
|
||||
|
||||
R0.07a (April 14, 2009)
|
||||
|
||||
Septemberarated out OS dependent code on reentrant cfg.
|
||||
Added multiple sector size feature.
|
||||
|
||||
|
||||
|
||||
R0.07c (June 21, 2009)
|
||||
|
||||
Fixed f_unlink() can return FR_OK on error.
|
||||
Fixed wrong cache control in f_lseek().
|
||||
Added relative path feature.
|
||||
Added f_chdir() and f_chdrive().
|
||||
Added proper case conversion to extended character.
|
||||
|
||||
|
||||
|
||||
R0.07e (November 03, 2009)
|
||||
|
||||
Septemberarated out configuration options from ff.h to ffconf.h.
|
||||
Fixed f_unlink() fails to remove a sub-directory on _FS_RPATH.
|
||||
Fixed name matching error on the 13 character boundary.
|
||||
Added a configuration option, _LFN_UNICODE.
|
||||
Changed f_readdir() to return the SFN with always upper case on non-LFN cfg.
|
||||
|
||||
|
||||
|
||||
R0.08 (May 15, 2010)
|
||||
|
||||
Added a memory configuration option. (_USE_LFN = 3)
|
||||
Added file lock feature. (_FS_SHARE)
|
||||
Added fast seek feature. (_USE_FASTSEEK)
|
||||
Changed some types on the API, XCHAR->TCHAR.
|
||||
Changed .fname in the FILINFO structure on Unicode cfg.
|
||||
String functions support UTF-8 encoding files on Unicode cfg.
|
||||
|
||||
|
||||
|
||||
R0.08a (August 16, 2010)
|
||||
|
||||
Added f_getcwd(). (_FS_RPATH = 2)
|
||||
Added sector erase feature. (_USE_ERASE)
|
||||
Moved file lock semaphore table from fs object to the bss.
|
||||
Fixed f_mkfs() creates wrong FAT32 volume.
|
||||
|
||||
|
||||
|
||||
R0.08b (January 15, 2011)
|
||||
|
||||
Fast seek feature is also applied to f_read() and f_write().
|
||||
f_lseek() reports required table size on creating CLMP.
|
||||
Extended format syntax of f_printf().
|
||||
Ignores duplicated directory separators in given path name.
|
||||
|
||||
|
||||
|
||||
R0.09 (September 06, 2011)
|
||||
|
||||
f_mkfs() supports multiple partition to complete the multiple partition feature.
|
||||
Added f_fdisk().
|
||||
|
||||
|
||||
|
||||
R0.09a (August 27, 2012)
|
||||
|
||||
Changed f_open() and f_opendir() reject null object pointer to avoid crash.
|
||||
Changed option name _FS_SHARE to _FS_LOCK.
|
||||
Fixed assertion failure due to OS/2 EA on FAT12/16 volume.
|
||||
|
||||
|
||||
|
||||
R0.09b (January 24, 2013)
|
||||
|
||||
Added f_setlabel() and f_getlabel().
|
||||
|
||||
|
||||
|
||||
R0.10 (October 02, 2013)
|
||||
|
||||
Added selection of character encoding on the file. (_STRF_ENCODE)
|
||||
Added f_closedir().
|
||||
Added forced full FAT scan for f_getfree(). (_FS_NOFSINFO)
|
||||
Added forced mount feature with changes of f_mount().
|
||||
Improved behavior of volume auto detection.
|
||||
Improved write throughput of f_puts() and f_printf().
|
||||
Changed argument of f_chdrive(), f_mkfs(), disk_read() and disk_write().
|
||||
Fixed f_write() can be truncated when the file size is close to 4GB.
|
||||
Fixed f_open(), f_mkdir() and f_setlabel() can return incorrect value on error.
|
||||
|
||||
|
||||
|
||||
R0.10a (January 15, 2014)
|
||||
|
||||
Added arbitrary strings as drive number in the path name. (_STR_VOLUME_ID)
|
||||
Added a configuration option of minimum sector size. (_MIN_SS)
|
||||
2nd argument of f_rename() can have a drive number and it will be ignored.
|
||||
Fixed f_mount() with forced mount fails when drive number is >= 1. (appeared at R0.10)
|
||||
Fixed f_close() invalidates the file object without volume lock.
|
||||
Fixed f_closedir() returns but the volume lock is left acquired. (appeared at R0.10)
|
||||
Fixed creation of an entry with LFN fails on too many SFN collisions. (appeared at R0.07)
|
||||
|
||||
|
||||
|
||||
R0.10b (May 19, 2014)
|
||||
|
||||
Fixed a hard error in the disk I/O layer can collapse the directory entry.
|
||||
Fixed LFN entry is not deleted when delete/rename an object with lossy converted SFN. (appeared at R0.07)
|
||||
|
||||
|
||||
|
||||
R0.10c (November 09, 2014)
|
||||
|
||||
Added a configuration option for the platforms without RTC. (_FS_NORTC)
|
||||
Changed option name _USE_ERASE to _USE_TRIM.
|
||||
Fixed volume label created by Mac OS X cannot be retrieved with f_getlabel(). (appeared at R0.09b)
|
||||
Fixed a potential problem of FAT access that can appear on disk error.
|
||||
Fixed null pointer dereference on attempting to delete the root direcotry. (appeared at R0.08)
|
||||
|
||||
|
||||
|
||||
R0.11 (February 09, 2015)
|
||||
|
||||
Added f_findfirst(), f_findnext() and f_findclose(). (_USE_FIND)
|
||||
Fixed f_unlink() does not remove cluster chain of the file. (appeared at R0.10c)
|
||||
Fixed _FS_NORTC option does not work properly. (appeared at R0.10c)
|
||||
|
||||
|
||||
|
||||
R0.11a (September 05, 2015)
|
||||
|
||||
Fixed wrong media change can lead a deadlock at thread-safe configuration.
|
||||
Added code page 771, 860, 861, 863, 864, 865 and 869. (_CODE_PAGE)
|
||||
Removed some code pages actually not exist on the standard systems. (_CODE_PAGE)
|
||||
Fixed errors in the case conversion teble of code page 437 and 850 (ff.c).
|
||||
Fixed errors in the case conversion teble of Unicode (cc*.c).
|
||||
|
||||
|
||||
|
||||
R0.12 (April 12, 2016)
|
||||
|
||||
Added support for exFAT file system. (_FS_EXFAT)
|
||||
Added f_expand(). (_USE_EXPAND)
|
||||
Changed some members in FINFO structure and behavior of f_readdir().
|
||||
Added an option _USE_CHMOD.
|
||||
Removed an option _WORD_ACCESS.
|
||||
Fixed errors in the case conversion table of Unicode (cc*.c).
|
||||
|
||||
|
||||
|
||||
R0.12a (July 10, 2016)
|
||||
|
||||
Added support for creating exFAT volume with some changes of f_mkfs().
|
||||
Added a file open method FA_OPEN_APPEND. An f_lseek() following f_open() is no longer needed.
|
||||
f_forward() is available regardless of _FS_TINY.
|
||||
Fixed f_mkfs() creates wrong volume. (appeared at R0.12)
|
||||
Fixed wrong memory read in create_name(). (appeared at R0.12)
|
||||
Fixed compilation fails at some configurations, _USE_FASTSEEK and _USE_FORWARD.
|
||||
|
||||
|
||||
|
||||
R0.12b (September 04, 2016)
|
||||
|
||||
Made f_rename() be able to rename objects with the same name but case.
|
||||
Fixed an error in the case conversion teble of code page 866. (ff.c)
|
||||
Fixed writing data is truncated at the file offset 4GiB on the exFAT volume. (appeared at R0.12)
|
||||
Fixed creating a file in the root directory of exFAT volume can fail. (appeared at R0.12)
|
||||
Fixed f_mkfs() creating exFAT volume with too small cluster size can collapse unallocated memory. (appeared at R0.12)
|
||||
Fixed wrong object name can be returned when read directory at Unicode cfg. (appeared at R0.12)
|
||||
Fixed large file allocation/removing on the exFAT volume collapses allocation bitmap. (appeared at R0.12)
|
||||
Fixed some internal errors in f_expand() and f_lseek(). (appeared at R0.12)
|
||||
|
||||
|
||||
|
||||
R0.12c (March 04, 2017)
|
||||
|
||||
Improved write throughput at the fragmented file on the exFAT volume.
|
||||
Made memory usage for exFAT be able to be reduced as decreasing _MAX_LFN.
|
||||
Fixed successive f_getfree() can return wrong count on the FAT12/16 volume. (appeared at R0.12)
|
||||
Fixed configuration option _VOLUMES cannot be set 10. (appeared at R0.10c)
|
||||
|
||||
|
||||
|
||||
R0.13 (May 21, 2017)
|
||||
|
||||
Changed heading character of configuration keywords "_" to "FF_".
|
||||
Removed ASCII-only configuration, FF_CODE_PAGE = 1. Use FF_CODE_PAGE = 437 instead.
|
||||
Added f_setcp(), run-time code page configuration. (FF_CODE_PAGE = 0)
|
||||
Improved cluster allocation time on stretch a deep buried cluster chain.
|
||||
Improved processing time of f_mkdir() with large cluster size by using FF_USE_LFN = 3.
|
||||
Improved NoFatChain flag of the fragmented file to be set after it is truncated and got contiguous.
|
||||
Fixed archive attribute is left not set when a file on the exFAT volume is renamed. (appeared at R0.12)
|
||||
Fixed exFAT FAT entry can be collapsed when write or lseek operation to the existing file is done. (appeared at R0.12c)
|
||||
Fixed creating a file can fail when a new cluster allocation to the exFAT directory occures. (appeared at R0.12c)
|
||||
|
||||
|
||||
|
||||
R0.13a (October 14, 2017)
|
||||
|
||||
Added support for UTF-8 encoding on the API. (FF_LFN_UNICODE = 2)
|
||||
Added options for file name output buffer. (FF_LFN_BUF, FF_SFN_BUF).
|
||||
Added dynamic memory allocation option for working buffer of f_mkfs() and f_fdisk().
|
||||
Fixed f_fdisk() and f_mkfs() create the partition table with wrong CHS parameters. (appeared at R0.09)
|
||||
Fixed f_unlink() can cause lost clusters at fragmented file on the exFAT volume. (appeared at R0.12c)
|
||||
Fixed f_setlabel() rejects some valid characters for exFAT volume. (appeared at R0.12)
|
||||
|
||||
|
||||
|
||||
R0.13b (April 07, 2018)
|
||||
|
||||
Added support for UTF-32 encoding on the API. (FF_LFN_UNICODE = 3)
|
||||
Added support for Unix style volume ID. (FF_STR_VOLUME_ID = 2)
|
||||
Fixed accesing any object on the exFAT root directory beyond the cluster boundary can fail. (appeared at R0.12c)
|
||||
Fixed f_setlabel() does not reject some invalid characters. (appeared at R0.09b)
|
||||
|
||||
|
||||
|
||||
R0.13c (October 14, 2018)
|
||||
Supported stdint.h for C99 and later. (integer.h was included in ff.h)
|
||||
Fixed reading a directory gets infinite loop when the last directory entry is not empty. (appeared at R0.12)
|
||||
Fixed creating a sub-directory in the fragmented sub-directory on the exFAT volume collapses FAT chain of the parent directory. (appeared at R0.12)
|
||||
Fixed f_getcwd() cause output buffer overrun when the buffer has a valid drive number. (appeared at R0.13b)
|
||||
|
||||
|
||||
|
||||
R0.14 (October 14, 2019)
|
||||
Added support for 64-bit LBA and GUID partition table (FF_LBA64 = 1)
|
||||
Changed some API functions, f_mkfs() and f_fdisk().
|
||||
Fixed f_open() function cannot find the file with file name in length of FF_MAX_LFN characters.
|
||||
Fixed f_readdir() function cannot retrieve long file names in length of FF_MAX_LFN - 1 characters.
|
||||
Fixed f_readdir() function returns file names with wrong case conversion. (appeared at R0.12)
|
||||
Fixed f_mkfs() function can fail to create exFAT volume in the second partition. (appeared at R0.12)
|
||||
|
||||
|
||||
R0.14a (December 5, 2020)
|
||||
Limited number of recursive calls in f_findnext().
|
||||
Fixed old floppy disks formatted with MS-DOS 2.x and 3.x cannot be mounted.
|
||||
Fixed some compiler warnings.
|
||||
|
||||
|
||||
|
||||
R0.14b (April 17, 2021)
|
||||
Made FatFs uses standard library <string.h> for copy, compare and search instead of built-in string functions.
|
||||
Added support for long long integer and floating point to f_printf(). (FF_STRF_LLI and FF_STRF_FP)
|
||||
Made path name parser ignore the terminating separator to allow "dir/".
|
||||
Improved the compatibility in Unix style path name feature.
|
||||
Fixed the file gets dead-locked when f_open() failed with some conditions. (appeared at R0.12a)
|
||||
Fixed f_mkfs() can create wrong exFAT volume due to a timing dependent error. (appeared at R0.12)
|
||||
Fixed code page 855 cannot be set by f_setcp().
|
||||
Fixed some compiler warnings.
|
||||
|
||||
|
||||
|
||||
R0.15 (November 6, 2022)
|
||||
Changed user provided synchronization functions in order to completely eliminate the platform dependency from FatFs code.
|
||||
FF_SYNC_t is removed from the configuration options.
|
||||
Fixed a potential error in f_mount when FF_FS_REENTRANT.
|
||||
Fixed file lock control FF_FS_LOCK is not mutal excluded when FF_FS_REENTRANT && FF_VOLUMES > 1 is true.
|
||||
Fixed f_mkfs() creates broken exFAT volume when the size of volume is >= 2^32 sectors.
|
||||
Fixed string functions cannot write the unicode characters not in BMP when FF_LFN_UNICODE == 2 (UTF-8).
|
||||
Fixed a compatibility issue in identification of GPT header.
|
||||
|
||||
|
||||
|
||||
R0.15a (November 22, 2024)
|
||||
Fixed a complie error when FF_FS_LOCK != 0.
|
||||
Fixed a potential issue when work FatFs concurrency with FF_FS_REENTRANT, FF_VOLUMES >= 2 and FF_FS_LOCK > 0.
|
||||
Made f_setlabel() accept a volume label in Unix style volume ID when FF_STR_VOLUME_ID == 2.
|
||||
Made FatFs update PercInUse field in exFAT VBR. (A preceding f_getfree() is needed for the accuracy)
|
||||
|
21
software/sys_controller/fatfs/source/00readme.txt
Normal file
21
software/sys_controller/fatfs/source/00readme.txt
Normal file
@ -0,0 +1,21 @@
|
||||
FatFs Module Source Files R0.15
|
||||
|
||||
|
||||
FILES
|
||||
|
||||
00readme.txt This file.
|
||||
00history.txt Revision history.
|
||||
ff.c FatFs module.
|
||||
ffconf.h Configuration file of FatFs module.
|
||||
ff.h Common include file for FatFs and application module.
|
||||
diskio.h Common include file for FatFs and disk I/O module.
|
||||
diskio.c An example of glue function to attach existing disk I/O module to FatFs.
|
||||
ffunicode.c Optional Unicode utility functions.
|
||||
ffsystem.c An example of optional O/S related functions.
|
||||
|
||||
|
||||
Low level disk I/O module is not included in this archive because the FatFs
|
||||
module is only a generic file system layer and it does not depend on any specific
|
||||
storage device. You need to provide a low level disk I/O module written to
|
||||
control the storage device that attached to the target system.
|
||||
|
128
software/sys_controller/fatfs/source/diskio.c
Normal file
128
software/sys_controller/fatfs/source/diskio.c
Normal file
@ -0,0 +1,128 @@
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Low level disk I/O module SKELETON for FatFs (C)ChaN, 2019 */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* If a working storage control module is available, it should be */
|
||||
/* attached to the FatFs via a glue function rather than modifying it. */
|
||||
/* This is an example of glue functions to attach various exsisting */
|
||||
/* storage control modules to the FatFs module with a defined API. */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
#include "ff.h" /* Obtains integer types */
|
||||
#include "diskio.h" /* Declarations of disk functions */
|
||||
#include "sd_io.h"
|
||||
#include "sysconfig.h"
|
||||
|
||||
extern SD_DEV sdcard_dev;
|
||||
|
||||
/* Definitions of physical drive number for each drive */
|
||||
#define DEV_RAM 0 /* Example: Map Ramdisk to physical drive 0 */
|
||||
#define DEV_MMC 1 /* Example: Map MMC/SD card to physical drive 1 */
|
||||
#define DEV_USB 2 /* Example: Map USB MSD to physical drive 2 */
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Get Drive Status */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
DSTATUS disk_status (
|
||||
BYTE pdrv /* Physical drive nmuber to identify the drive */
|
||||
)
|
||||
{
|
||||
//res = SD_Status(&sdcard_dev);
|
||||
|
||||
return sdcard_dev.mount ? RES_OK : STA_NODISK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Inidialize a Drive */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
DSTATUS disk_initialize (
|
||||
BYTE pdrv /* Physical drive nmuber to identify the drive */
|
||||
)
|
||||
{
|
||||
DSTATUS stat;
|
||||
SDRESULTS res;
|
||||
|
||||
if (sdcard_dev.mount)
|
||||
return SD_OK;
|
||||
|
||||
res = SD_Init(&sdcard_dev);
|
||||
|
||||
return (res == SD_OK) ? RES_OK : STA_NOINIT;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Read Sector(s) */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
DRESULT disk_read (
|
||||
BYTE pdrv, /* Physical drive nmuber to identify the drive */
|
||||
BYTE *buff, /* Data buffer to store read data */
|
||||
LBA_t sector, /* Start sector in LBA */
|
||||
UINT count /* Number of sectors to read */
|
||||
)
|
||||
{
|
||||
SDRESULTS res;
|
||||
|
||||
if (!sdcard_dev.mount)
|
||||
return STA_NOINIT;
|
||||
|
||||
res = SD_Read(&sdcard_dev, buff, sector, 0, count*SD_BLK_SIZE);
|
||||
|
||||
return (res == SD_OK) ? RES_OK : RES_PARERR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Write Sector(s) */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
#if FF_FS_READONLY == 0
|
||||
|
||||
DRESULT disk_write (
|
||||
BYTE pdrv, /* Physical drive nmuber to identify the drive */
|
||||
const BYTE *buff, /* Data to be written */
|
||||
LBA_t sector, /* Start sector in LBA */
|
||||
UINT count /* Number of sectors to write */
|
||||
)
|
||||
{
|
||||
SDRESULTS res;
|
||||
int i;
|
||||
|
||||
if (!sdcard_dev.mount)
|
||||
return STA_NOINIT;
|
||||
|
||||
for (i=0; i<count; i++) {
|
||||
res = SD_Write(&sdcard_dev, (void*)&buff[i*SD_BLK_SIZE], sector);
|
||||
if (res != SD_OK)
|
||||
return RES_PARERR;
|
||||
}
|
||||
|
||||
return RES_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Miscellaneous Functions */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
DRESULT disk_ioctl (
|
||||
BYTE pdrv, /* Physical drive nmuber (0..) */
|
||||
BYTE cmd, /* Control code */
|
||||
void *buff /* Buffer to send/receive control data */
|
||||
)
|
||||
{
|
||||
DRESULT res;
|
||||
int result;
|
||||
|
||||
return RES_PARERR;
|
||||
}
|
||||
|
77
software/sys_controller/fatfs/source/diskio.h
Normal file
77
software/sys_controller/fatfs/source/diskio.h
Normal file
@ -0,0 +1,77 @@
|
||||
/*-----------------------------------------------------------------------/
|
||||
/ Low level disk interface modlue include file (C)ChaN, 2019 /
|
||||
/-----------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _DISKIO_DEFINED
|
||||
#define _DISKIO_DEFINED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Status of Disk Functions */
|
||||
typedef BYTE DSTATUS;
|
||||
|
||||
/* Results of Disk Functions */
|
||||
typedef enum {
|
||||
RES_OK = 0, /* 0: Successful */
|
||||
RES_ERROR, /* 1: R/W Error */
|
||||
RES_WRPRT, /* 2: Write Protected */
|
||||
RES_NOTRDY, /* 3: Not Ready */
|
||||
RES_PARERR /* 4: Invalid Parameter */
|
||||
} DRESULT;
|
||||
|
||||
|
||||
/*---------------------------------------*/
|
||||
/* Prototypes for disk control functions */
|
||||
|
||||
|
||||
DSTATUS disk_initialize (BYTE pdrv);
|
||||
DSTATUS disk_status (BYTE pdrv);
|
||||
DRESULT disk_read (BYTE pdrv, BYTE* buff, LBA_t sector, UINT count);
|
||||
DRESULT disk_write (BYTE pdrv, const BYTE* buff, LBA_t sector, UINT count);
|
||||
DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
|
||||
|
||||
|
||||
/* Disk Status Bits (DSTATUS) */
|
||||
|
||||
#define STA_NOINIT 0x01 /* Drive not initialized */
|
||||
#define STA_NODISK 0x02 /* No medium in the drive */
|
||||
#define STA_PROTECT 0x04 /* Write protected */
|
||||
|
||||
|
||||
/* Command code for disk_ioctrl fucntion */
|
||||
|
||||
/* Generic command (Used by FatFs) */
|
||||
#define CTRL_SYNC 0 /* Complete pending write process (needed at FF_FS_READONLY == 0) */
|
||||
#define GET_SECTOR_COUNT 1 /* Get media size (needed at FF_USE_MKFS == 1) */
|
||||
#define GET_SECTOR_SIZE 2 /* Get sector size (needed at FF_MAX_SS != FF_MIN_SS) */
|
||||
#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at FF_USE_MKFS == 1) */
|
||||
#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at FF_USE_TRIM == 1) */
|
||||
|
||||
/* Generic command (Not used by FatFs) */
|
||||
#define CTRL_POWER 5 /* Get/Set power status */
|
||||
#define CTRL_LOCK 6 /* Lock/Unlock media removal */
|
||||
#define CTRL_EJECT 7 /* Eject media */
|
||||
#define CTRL_FORMAT 8 /* Create physical format on the media */
|
||||
|
||||
/* MMC/SDC specific ioctl command */
|
||||
#define MMC_GET_TYPE 10 /* Get card type */
|
||||
#define MMC_GET_CSD 11 /* Get CSD */
|
||||
#define MMC_GET_CID 12 /* Get CID */
|
||||
#define MMC_GET_OCR 13 /* Get OCR */
|
||||
#define MMC_GET_SDSTAT 14 /* Get SD status */
|
||||
#define ISDIO_READ 55 /* Read data form SD iSDIO register */
|
||||
#define ISDIO_WRITE 56 /* Write data to SD iSDIO register */
|
||||
#define ISDIO_MRITE 57 /* Masked write data to SD iSDIO register */
|
||||
|
||||
/* ATA/CF specific ioctl command */
|
||||
#define ATA_GET_REV 20 /* Get F/W revision */
|
||||
#define ATA_GET_MODEL 21 /* Get model name */
|
||||
#define ATA_GET_SN 22 /* Get serial number */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
7181
software/sys_controller/fatfs/source/ff.c
Normal file
7181
software/sys_controller/fatfs/source/ff.c
Normal file
File diff suppressed because it is too large
Load Diff
431
software/sys_controller/fatfs/source/ff.h
Normal file
431
software/sys_controller/fatfs/source/ff.h
Normal file
@ -0,0 +1,431 @@
|
||||
/*----------------------------------------------------------------------------/
|
||||
/ FatFs - Generic FAT Filesystem module R0.15a /
|
||||
/-----------------------------------------------------------------------------/
|
||||
/
|
||||
/ Copyright (C) 2024, ChaN, all right reserved.
|
||||
/
|
||||
/ FatFs module is an open source software. Redistribution and use of FatFs in
|
||||
/ source and binary forms, with or without modification, are permitted provided
|
||||
/ that the following condition is met:
|
||||
|
||||
/ 1. Redistributions of source code must retain the above copyright notice,
|
||||
/ this condition and the following disclaimer.
|
||||
/
|
||||
/ This software is provided by the copyright holder and contributors "AS IS"
|
||||
/ and any warranties related to this software are DISCLAIMED.
|
||||
/ The copyright owner or contributors be NOT LIABLE for any damages caused
|
||||
/ by use of this software.
|
||||
/
|
||||
/----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef FF_DEFINED
|
||||
#define FF_DEFINED 5380 /* Revision ID */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if !defined(FFCONF_DEF)
|
||||
#include "ffconf.h" /* FatFs configuration options */
|
||||
#endif
|
||||
#if FF_DEFINED != FFCONF_DEF
|
||||
#error Wrong configuration file (ffconf.h).
|
||||
#endif
|
||||
|
||||
|
||||
/* Integer types used for FatFs API */
|
||||
|
||||
#if defined(_WIN32) /* Windows VC++ (for development only) */
|
||||
#define FF_INTDEF 2
|
||||
#include <windows.h>
|
||||
typedef unsigned __int64 QWORD;
|
||||
#include <float.h>
|
||||
#define isnan(v) _isnan(v)
|
||||
#define isinf(v) (!_finite(v))
|
||||
|
||||
#elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__cplusplus) /* C99 or later */
|
||||
#define FF_INTDEF 2
|
||||
#include <stdint.h>
|
||||
typedef unsigned int UINT; /* int must be 16-bit or 32-bit */
|
||||
typedef unsigned char BYTE; /* char must be 8-bit */
|
||||
typedef uint16_t WORD; /* 16-bit unsigned */
|
||||
typedef uint32_t DWORD; /* 32-bit unsigned */
|
||||
typedef uint64_t QWORD; /* 64-bit unsigned */
|
||||
typedef WORD WCHAR; /* UTF-16 code unit */
|
||||
|
||||
#else /* Earlier than C99 */
|
||||
#define FF_INTDEF 1
|
||||
typedef unsigned int UINT; /* int must be 16-bit or 32-bit */
|
||||
typedef unsigned char BYTE; /* char must be 8-bit */
|
||||
typedef unsigned short WORD; /* short must be 16-bit */
|
||||
typedef unsigned long DWORD; /* long must be 32-bit */
|
||||
typedef WORD WCHAR; /* UTF-16 code unit */
|
||||
#endif
|
||||
|
||||
|
||||
/* Type of file size and LBA variables */
|
||||
|
||||
#if FF_FS_EXFAT
|
||||
#if FF_INTDEF != 2
|
||||
#error exFAT feature wants C99 or later
|
||||
#endif
|
||||
typedef QWORD FSIZE_t;
|
||||
#if FF_LBA64
|
||||
typedef QWORD LBA_t;
|
||||
#else
|
||||
typedef DWORD LBA_t;
|
||||
#endif
|
||||
#else
|
||||
#if FF_LBA64
|
||||
#error exFAT needs to be enabled when enable 64-bit LBA
|
||||
#endif
|
||||
typedef DWORD FSIZE_t;
|
||||
typedef DWORD LBA_t;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Type of path name strings on FatFs API (TCHAR) */
|
||||
|
||||
#if FF_USE_LFN && FF_LFN_UNICODE == 1 /* Unicode in UTF-16 encoding */
|
||||
typedef WCHAR TCHAR;
|
||||
#define _T(x) L ## x
|
||||
#define _TEXT(x) L ## x
|
||||
#elif FF_USE_LFN && FF_LFN_UNICODE == 2 /* Unicode in UTF-8 encoding */
|
||||
typedef char TCHAR;
|
||||
#define _T(x) u8 ## x
|
||||
#define _TEXT(x) u8 ## x
|
||||
#elif FF_USE_LFN && FF_LFN_UNICODE == 3 /* Unicode in UTF-32 encoding */
|
||||
typedef DWORD TCHAR;
|
||||
#define _T(x) U ## x
|
||||
#define _TEXT(x) U ## x
|
||||
#elif FF_USE_LFN && (FF_LFN_UNICODE < 0 || FF_LFN_UNICODE > 3)
|
||||
#error Wrong FF_LFN_UNICODE setting
|
||||
#else /* ANSI/OEM code in SBCS/DBCS */
|
||||
typedef char TCHAR;
|
||||
#define _T(x) x
|
||||
#define _TEXT(x) x
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Definitions of volume management */
|
||||
|
||||
#if FF_MULTI_PARTITION /* Multiple partition configuration */
|
||||
typedef struct {
|
||||
BYTE pd; /* Associated physical drive */
|
||||
BYTE pt; /* Associated partition (0:Auto detect, 1-4:Forced partition) */
|
||||
} PARTITION;
|
||||
extern PARTITION VolToPart[]; /* Volume to partition mapping table */
|
||||
#endif
|
||||
|
||||
#if FF_STR_VOLUME_ID
|
||||
#ifndef FF_VOLUME_STRS
|
||||
extern const char* VolumeStr[FF_VOLUMES]; /* User defined volume ID table */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Filesystem object structure (FATFS) */
|
||||
|
||||
typedef struct {
|
||||
BYTE fs_type; /* Filesystem type (0:blank filesystem object) */
|
||||
BYTE pdrv; /* Volume hosting physical drive */
|
||||
BYTE ldrv; /* Logical drive number (used only when FF_FS_REENTRANT) */
|
||||
BYTE n_fats; /* Number of FATs (1 or 2) */
|
||||
BYTE wflag; /* win[] status (1:dirty) */
|
||||
BYTE fsi_flag; /* Allocation information control (b7:disabled, b0:dirty) */
|
||||
WORD id; /* Volume mount ID */
|
||||
WORD n_rootdir; /* Number of root directory entries (FAT12/16) */
|
||||
WORD csize; /* Cluster size [sectors] */
|
||||
#if FF_MAX_SS != FF_MIN_SS
|
||||
WORD ssize; /* Sector size (512, 1024, 2048 or 4096) */
|
||||
#endif
|
||||
#if FF_USE_LFN
|
||||
WCHAR* lfnbuf; /* LFN working buffer */
|
||||
#endif
|
||||
#if FF_FS_EXFAT
|
||||
BYTE* dirbuf; /* Directory entry block scratch pad buffer for exFAT */
|
||||
#endif
|
||||
#if !FF_FS_READONLY
|
||||
DWORD last_clst; /* Last allocated cluster (Unknown if >= n_fatent) */
|
||||
DWORD free_clst; /* Number of free clusters (Unknown if >= n_fatent-2) */
|
||||
#endif
|
||||
#if FF_FS_RPATH
|
||||
DWORD cdir; /* Current directory start cluster (0:root) */
|
||||
#if FF_FS_EXFAT
|
||||
DWORD cdc_scl; /* Containing directory start cluster (invalid when cdir is 0) */
|
||||
DWORD cdc_size; /* b31-b8:Size of containing directory, b7-b0: Chain status */
|
||||
DWORD cdc_ofs; /* Offset in the containing directory (invalid when cdir is 0) */
|
||||
#endif
|
||||
#endif
|
||||
DWORD n_fatent; /* Number of FAT entries (number of clusters + 2) */
|
||||
DWORD fsize; /* Number of sectors per FAT */
|
||||
LBA_t volbase; /* Volume base sector */
|
||||
LBA_t fatbase; /* FAT base sector */
|
||||
LBA_t dirbase; /* Root directory base sector (FAT12/16) or cluster (FAT32/exFAT) */
|
||||
LBA_t database; /* Data base sector */
|
||||
#if FF_FS_EXFAT
|
||||
LBA_t bitbase; /* Allocation bitmap base sector */
|
||||
#endif
|
||||
LBA_t winsect; /* Current sector appearing in the win[] */
|
||||
BYTE win[FF_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */
|
||||
} FATFS;
|
||||
|
||||
|
||||
|
||||
/* Object ID and allocation information (FFOBJID) */
|
||||
|
||||
typedef struct {
|
||||
FATFS* fs; /* Pointer to the hosting volume of this object */
|
||||
WORD id; /* Hosting volume's mount ID */
|
||||
BYTE attr; /* Object attribute */
|
||||
BYTE stat; /* Object chain status (b1-0: =0:not contiguous, =2:contiguous, =3:fragmented in this session, b2:sub-directory stretched) */
|
||||
DWORD sclust; /* Object data start cluster (0:no cluster or root directory) */
|
||||
FSIZE_t objsize; /* Object size (valid when sclust != 0) */
|
||||
#if FF_FS_EXFAT
|
||||
DWORD n_cont; /* Size of first fragment - 1 (valid when stat == 3) */
|
||||
DWORD n_frag; /* Size of last fragment needs to be written to FAT (valid when not zero) */
|
||||
DWORD c_scl; /* Containing directory start cluster (valid when sclust != 0) */
|
||||
DWORD c_size; /* b31-b8:Size of containing directory, b7-b0: Chain status (valid when c_scl != 0) */
|
||||
DWORD c_ofs; /* Offset in the containing directory (valid when file object and sclust != 0) */
|
||||
#endif
|
||||
#if FF_FS_LOCK
|
||||
UINT lockid; /* File lock ID origin from 1 (index of file semaphore table Files[]) */
|
||||
#endif
|
||||
} FFOBJID;
|
||||
|
||||
|
||||
|
||||
/* File object structure (FIL) */
|
||||
|
||||
typedef struct {
|
||||
FFOBJID obj; /* Object identifier (must be the 1st member to detect invalid object pointer) */
|
||||
BYTE flag; /* File status flags */
|
||||
BYTE err; /* Abort flag (error code) */
|
||||
FSIZE_t fptr; /* File read/write pointer (Zeroed on file open) */
|
||||
DWORD clust; /* Current cluster of fpter (invalid when fptr is 0) */
|
||||
LBA_t sect; /* Sector number appearing in buf[] (0:invalid) */
|
||||
#if !FF_FS_READONLY
|
||||
LBA_t dir_sect; /* Sector number containing the directory entry (not used at exFAT) */
|
||||
BYTE* dir_ptr; /* Pointer to the directory entry in the win[] (not used at exFAT) */
|
||||
#endif
|
||||
#if FF_USE_FASTSEEK
|
||||
DWORD* cltbl; /* Pointer to the cluster link map table (nulled on open, set by application) */
|
||||
#endif
|
||||
#if !FF_FS_TINY
|
||||
BYTE buf[FF_MAX_SS]; /* File private data read/write window */
|
||||
#endif
|
||||
} FIL;
|
||||
|
||||
|
||||
|
||||
/* Directory object structure (DIR) */
|
||||
|
||||
typedef struct {
|
||||
FFOBJID obj; /* Object identifier */
|
||||
DWORD dptr; /* Current read/write offset */
|
||||
DWORD clust; /* Current cluster */
|
||||
LBA_t sect; /* Current sector (0:Read operation has terminated) */
|
||||
BYTE* dir; /* Pointer to the directory item in the win[] */
|
||||
BYTE fn[12]; /* SFN (in/out) {body[8],ext[3],status[1]} */
|
||||
#if FF_USE_LFN
|
||||
DWORD blk_ofs; /* Offset of current entry block being processed (0xFFFFFFFF:Invalid) */
|
||||
#endif
|
||||
#if FF_USE_FIND
|
||||
const TCHAR* pat; /* Pointer to the name matching pattern */
|
||||
#endif
|
||||
} DIR;
|
||||
|
||||
|
||||
|
||||
/* File information structure (FILINFO) */
|
||||
|
||||
typedef struct {
|
||||
FSIZE_t fsize; /* File size */
|
||||
WORD fdate; /* Modified date */
|
||||
WORD ftime; /* Modified time */
|
||||
BYTE fattrib; /* File attribute */
|
||||
#if FF_USE_LFN
|
||||
TCHAR altname[FF_SFN_BUF + 1];/* Alternative file name */
|
||||
TCHAR fname[FF_LFN_BUF + 1]; /* Primary file name */
|
||||
#else
|
||||
TCHAR fname[12 + 1]; /* File name */
|
||||
#endif
|
||||
} FILINFO;
|
||||
|
||||
|
||||
|
||||
/* Format parameter structure (MKFS_PARM) */
|
||||
|
||||
typedef struct {
|
||||
BYTE fmt; /* Format option (FM_FAT, FM_FAT32, FM_EXFAT and FM_SFD) */
|
||||
BYTE n_fat; /* Number of FATs */
|
||||
UINT align; /* Data area alignment (sector) */
|
||||
UINT n_root; /* Number of root directory entries */
|
||||
DWORD au_size; /* Cluster size (byte) */
|
||||
} MKFS_PARM;
|
||||
|
||||
|
||||
|
||||
/* File function return code (FRESULT) */
|
||||
|
||||
typedef enum {
|
||||
FR_OK = 0, /* (0) Function succeeded */
|
||||
FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */
|
||||
FR_INT_ERR, /* (2) Assertion failed */
|
||||
FR_NOT_READY, /* (3) The physical drive does not work */
|
||||
FR_NO_FILE, /* (4) Could not find the file */
|
||||
FR_NO_PATH, /* (5) Could not find the path */
|
||||
FR_INVALID_NAME, /* (6) The path name format is invalid */
|
||||
FR_DENIED, /* (7) Access denied due to a prohibited access or directory full */
|
||||
FR_EXIST, /* (8) Access denied due to a prohibited access */
|
||||
FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */
|
||||
FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */
|
||||
FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */
|
||||
FR_NOT_ENABLED, /* (12) The volume has no work area */
|
||||
FR_NO_FILESYSTEM, /* (13) Could not find a valid FAT volume */
|
||||
FR_MKFS_ABORTED, /* (14) The f_mkfs function aborted due to some problem */
|
||||
FR_TIMEOUT, /* (15) Could not take control of the volume within defined period */
|
||||
FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */
|
||||
FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated or given buffer is insufficient in size */
|
||||
FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > FF_FS_LOCK */
|
||||
FR_INVALID_PARAMETER /* (19) Given parameter is invalid */
|
||||
} FRESULT;
|
||||
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
/* FatFs Module Application Interface */
|
||||
/*--------------------------------------------------------------*/
|
||||
|
||||
FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */
|
||||
FRESULT f_close (FIL* fp); /* Close an open file object */
|
||||
FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from the file */
|
||||
FRESULT f_read_cc (FIL* fp, uint32_t* buff, UINT btr, UINT* br, UINT max_clusters); /* Collect cluster# */
|
||||
FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to the file */
|
||||
FRESULT f_lseek (FIL* fp, FSIZE_t ofs); /* Move file pointer of the file object */
|
||||
FRESULT f_truncate (FIL* fp); /* Truncate the file */
|
||||
FRESULT f_sync (FIL* fp); /* Flush cached data of the writing file */
|
||||
FRESULT f_opendir (DIR* dp, const TCHAR* path); /* Open a directory */
|
||||
FRESULT f_closedir (DIR* dp); /* Close an open directory */
|
||||
FRESULT f_readdir (DIR* dp, FILINFO* fno); /* Read a directory item */
|
||||
FRESULT f_findfirst (DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern); /* Find first file */
|
||||
FRESULT f_findnext (DIR* dp, FILINFO* fno); /* Find next file */
|
||||
FRESULT f_mkdir (const TCHAR* path); /* Create a sub directory */
|
||||
FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */
|
||||
FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */
|
||||
FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */
|
||||
FRESULT f_chmod (const TCHAR* path, BYTE attr, BYTE mask); /* Change attribute of a file/dir */
|
||||
FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change timestamp of a file/dir */
|
||||
FRESULT f_chdir (const TCHAR* path); /* Change current directory */
|
||||
FRESULT f_chdrive (const TCHAR* path); /* Change current drive */
|
||||
FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */
|
||||
FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */
|
||||
FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* vsn); /* Get volume label */
|
||||
FRESULT f_setlabel (const TCHAR* label); /* Set volume label */
|
||||
FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */
|
||||
FRESULT f_expand (FIL* fp, FSIZE_t fsz, BYTE opt); /* Allocate a contiguous block to the file */
|
||||
FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */
|
||||
FRESULT f_mkfs (const TCHAR* path, const MKFS_PARM* opt, void* work, UINT len); /* Create a FAT volume */
|
||||
FRESULT f_fdisk (BYTE pdrv, const LBA_t ptbl[], void* work); /* Divide a physical drive into some partitions */
|
||||
FRESULT f_setcp (WORD cp); /* Set current code page */
|
||||
int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */
|
||||
int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */
|
||||
int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */
|
||||
TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */
|
||||
|
||||
/* Some API fucntions are implemented as macro */
|
||||
|
||||
#define f_eof(fp) ((int)((fp)->fptr == (fp)->obj.objsize))
|
||||
#define f_error(fp) ((fp)->err)
|
||||
#define f_tell(fp) ((fp)->fptr)
|
||||
#define f_size(fp) ((fp)->obj.objsize)
|
||||
#define f_rewind(fp) f_lseek((fp), 0)
|
||||
#define f_rewinddir(dp) f_readdir((dp), 0)
|
||||
#define f_rmdir(path) f_unlink(path)
|
||||
#define f_unmount(path) f_mount(0, path, 0)
|
||||
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
/* Additional Functions */
|
||||
/*--------------------------------------------------------------*/
|
||||
|
||||
/* RTC function (provided by user) */
|
||||
#if !FF_FS_READONLY && !FF_FS_NORTC
|
||||
DWORD get_fattime (void); /* Get current time */
|
||||
#endif
|
||||
|
||||
|
||||
/* LFN support functions (defined in ffunicode.c) */
|
||||
|
||||
#if FF_USE_LFN >= 1
|
||||
WCHAR ff_oem2uni (WCHAR oem, WORD cp); /* OEM code to Unicode conversion */
|
||||
WCHAR ff_uni2oem (DWORD uni, WORD cp); /* Unicode to OEM code conversion */
|
||||
DWORD ff_wtoupper (DWORD uni); /* Unicode upper-case conversion */
|
||||
#endif
|
||||
|
||||
|
||||
/* O/S dependent functions (samples available in ffsystem.c) */
|
||||
|
||||
#if FF_USE_LFN == 3 /* Dynamic memory allocation */
|
||||
void* ff_memalloc (UINT msize); /* Allocate memory block */
|
||||
void ff_memfree (void* mblock); /* Free memory block */
|
||||
#endif
|
||||
#if FF_FS_REENTRANT /* Sync functions */
|
||||
int ff_mutex_create (int vol); /* Create a sync object */
|
||||
void ff_mutex_delete (int vol); /* Delete a sync object */
|
||||
int ff_mutex_take (int vol); /* Lock sync object */
|
||||
void ff_mutex_give (int vol); /* Unlock sync object */
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
/* Flags and Offset Address */
|
||||
/*--------------------------------------------------------------*/
|
||||
|
||||
/* File access mode and open method flags (3rd argument of f_open function) */
|
||||
#define FA_READ 0x01
|
||||
#define FA_WRITE 0x02
|
||||
#define FA_OPEN_EXISTING 0x00
|
||||
#define FA_CREATE_NEW 0x04
|
||||
#define FA_CREATE_ALWAYS 0x08
|
||||
#define FA_OPEN_ALWAYS 0x10
|
||||
#define FA_OPEN_APPEND 0x30
|
||||
|
||||
/* Fast seek controls (2nd argument of f_lseek function) */
|
||||
#define CREATE_LINKMAP ((FSIZE_t)0 - 1)
|
||||
|
||||
/* Format options (2nd argument of f_mkfs function) */
|
||||
#define FM_FAT 0x01
|
||||
#define FM_FAT32 0x02
|
||||
#define FM_EXFAT 0x04
|
||||
#define FM_ANY 0x07
|
||||
#define FM_SFD 0x08
|
||||
|
||||
/* Filesystem type (FATFS.fs_type) */
|
||||
#define FS_FAT12 1
|
||||
#define FS_FAT16 2
|
||||
#define FS_FAT32 3
|
||||
#define FS_EXFAT 4
|
||||
|
||||
/* File attribute bits for directory entry (FILINFO.fattrib) */
|
||||
#define AM_RDO 0x01 /* Read only */
|
||||
#define AM_HID 0x02 /* Hidden */
|
||||
#define AM_SYS 0x04 /* System */
|
||||
#define AM_DIR 0x10 /* Directory */
|
||||
#define AM_ARC 0x20 /* Archive */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FF_DEFINED */
|
208
software/sys_controller/fatfs/source/ffsystem.c
Normal file
208
software/sys_controller/fatfs/source/ffsystem.c
Normal file
@ -0,0 +1,208 @@
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* A Sample Code of User Provided OS Dependent Functions for FatFs */
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
#include "ff.h"
|
||||
|
||||
|
||||
#if FF_USE_LFN == 3 /* Use dynamic memory allocation */
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Allocate/Free a Memory Block */
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdlib.h> /* with POSIX API */
|
||||
|
||||
|
||||
void* ff_memalloc ( /* Returns pointer to the allocated memory block (null if not enough core) */
|
||||
UINT msize /* Number of bytes to allocate */
|
||||
)
|
||||
{
|
||||
return malloc((size_t)msize); /* Allocate a new memory block */
|
||||
}
|
||||
|
||||
|
||||
void ff_memfree (
|
||||
void* mblock /* Pointer to the memory block to free (no effect if null) */
|
||||
)
|
||||
{
|
||||
free(mblock); /* Free the memory block */
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#if FF_FS_REENTRANT /* Mutal exclusion */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Definitions of Mutex */
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
#define OS_TYPE 0 /* 0:Win32, 1:uITRON4.0, 2:uC/OS-II, 3:FreeRTOS, 4:CMSIS-RTOS */
|
||||
|
||||
|
||||
#if OS_TYPE == 0 /* Win32 */
|
||||
#include <windows.h>
|
||||
static HANDLE Mutex[FF_VOLUMES + 1]; /* Table of mutex handle */
|
||||
|
||||
#elif OS_TYPE == 1 /* uITRON */
|
||||
#include "itron.h"
|
||||
#include "kernel.h"
|
||||
static mtxid Mutex[FF_VOLUMES + 1]; /* Table of mutex ID */
|
||||
|
||||
#elif OS_TYPE == 2 /* uc/OS-II */
|
||||
#include "includes.h"
|
||||
static OS_EVENT *Mutex[FF_VOLUMES + 1]; /* Table of mutex pinter */
|
||||
|
||||
#elif OS_TYPE == 3 /* FreeRTOS */
|
||||
#include "FreeRTOS.h"
|
||||
#include "semphr.h"
|
||||
static SemaphoreHandle_t Mutex[FF_VOLUMES + 1]; /* Table of mutex handle */
|
||||
|
||||
#elif OS_TYPE == 4 /* CMSIS-RTOS */
|
||||
#include "cmsis_os.h"
|
||||
static osMutexId Mutex[FF_VOLUMES + 1]; /* Table of mutex ID */
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Create a Mutex */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* This function is called in f_mount function to create a new mutex
|
||||
/ or semaphore for the volume. When a 0 is returned, the f_mount function
|
||||
/ fails with FR_INT_ERR.
|
||||
*/
|
||||
|
||||
int ff_mutex_create ( /* Returns 1:Function succeeded or 0:Could not create the mutex */
|
||||
int vol /* Mutex ID: Volume mutex (0 to FF_VOLUMES - 1) or system mutex (FF_VOLUMES) */
|
||||
)
|
||||
{
|
||||
#if OS_TYPE == 0 /* Win32 */
|
||||
Mutex[vol] = CreateMutex(NULL, FALSE, NULL);
|
||||
return (int)(Mutex[vol] != INVALID_HANDLE_VALUE);
|
||||
|
||||
#elif OS_TYPE == 1 /* uITRON */
|
||||
T_CMTX cmtx = {TA_TPRI,1};
|
||||
|
||||
Mutex[vol] = acre_mtx(&cmtx);
|
||||
return (int)(Mutex[vol] > 0);
|
||||
|
||||
#elif OS_TYPE == 2 /* uC/OS-II */
|
||||
OS_ERR err;
|
||||
|
||||
Mutex[vol] = OSMutexCreate(0, &err);
|
||||
return (int)(err == OS_NO_ERR);
|
||||
|
||||
#elif OS_TYPE == 3 /* FreeRTOS */
|
||||
Mutex[vol] = xSemaphoreCreateMutex();
|
||||
return (int)(Mutex[vol] != NULL);
|
||||
|
||||
#elif OS_TYPE == 4 /* CMSIS-RTOS */
|
||||
osMutexDef(cmsis_os_mutex);
|
||||
|
||||
Mutex[vol] = osMutexCreate(osMutex(cmsis_os_mutex));
|
||||
return (int)(Mutex[vol] != NULL);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Delete a Mutex */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* This function is called in f_mount function to delete a mutex or
|
||||
/ semaphore of the volume created with ff_mutex_create function.
|
||||
*/
|
||||
|
||||
void ff_mutex_delete ( /* Returns 1:Function succeeded or 0:Could not delete due to an error */
|
||||
int vol /* Mutex ID: Volume mutex (0 to FF_VOLUMES - 1) or system mutex (FF_VOLUMES) */
|
||||
)
|
||||
{
|
||||
#if OS_TYPE == 0 /* Win32 */
|
||||
CloseHandle(Mutex[vol]);
|
||||
|
||||
#elif OS_TYPE == 1 /* uITRON */
|
||||
del_mtx(Mutex[vol]);
|
||||
|
||||
#elif OS_TYPE == 2 /* uC/OS-II */
|
||||
OS_ERR err;
|
||||
|
||||
OSMutexDel(Mutex[vol], OS_DEL_ALWAYS, &err);
|
||||
|
||||
#elif OS_TYPE == 3 /* FreeRTOS */
|
||||
vSemaphoreDelete(Mutex[vol]);
|
||||
|
||||
#elif OS_TYPE == 4 /* CMSIS-RTOS */
|
||||
osMutexDelete(Mutex[vol]);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Request a Grant to Access the Volume */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* This function is called on enter file functions to lock the volume.
|
||||
/ When a 0 is returned, the file function fails with FR_TIMEOUT.
|
||||
*/
|
||||
|
||||
int ff_mutex_take ( /* Returns 1:Succeeded or 0:Timeout */
|
||||
int vol /* Mutex ID: Volume mutex (0 to FF_VOLUMES - 1) or system mutex (FF_VOLUMES) */
|
||||
)
|
||||
{
|
||||
#if OS_TYPE == 0 /* Win32 */
|
||||
return (int)(WaitForSingleObject(Mutex[vol], FF_FS_TIMEOUT) == WAIT_OBJECT_0);
|
||||
|
||||
#elif OS_TYPE == 1 /* uITRON */
|
||||
return (int)(tloc_mtx(Mutex[vol], FF_FS_TIMEOUT) == E_OK);
|
||||
|
||||
#elif OS_TYPE == 2 /* uC/OS-II */
|
||||
OS_ERR err;
|
||||
|
||||
OSMutexPend(Mutex[vol], FF_FS_TIMEOUT, &err));
|
||||
return (int)(err == OS_NO_ERR);
|
||||
|
||||
#elif OS_TYPE == 3 /* FreeRTOS */
|
||||
return (int)(xSemaphoreTake(Mutex[vol], FF_FS_TIMEOUT) == pdTRUE);
|
||||
|
||||
#elif OS_TYPE == 4 /* CMSIS-RTOS */
|
||||
return (int)(osMutexWait(Mutex[vol], FF_FS_TIMEOUT) == osOK);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Release a Grant to Access the Volume */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* This function is called on leave file functions to unlock the volume.
|
||||
*/
|
||||
|
||||
void ff_mutex_give (
|
||||
int vol /* Mutex ID: Volume mutex (0 to FF_VOLUMES - 1) or system mutex (FF_VOLUMES) */
|
||||
)
|
||||
{
|
||||
#if OS_TYPE == 0 /* Win32 */
|
||||
ReleaseMutex(Mutex[vol]);
|
||||
|
||||
#elif OS_TYPE == 1 /* uITRON */
|
||||
unl_mtx(Mutex[vol]);
|
||||
|
||||
#elif OS_TYPE == 2 /* uC/OS-II */
|
||||
OSMutexPost(Mutex[vol]);
|
||||
|
||||
#elif OS_TYPE == 3 /* FreeRTOS */
|
||||
xSemaphoreGive(Mutex[vol]);
|
||||
|
||||
#elif OS_TYPE == 4 /* CMSIS-RTOS */
|
||||
osMutexRelease(Mutex[vol]);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* FF_FS_REENTRANT */
|
||||
|
15593
software/sys_controller/fatfs/source/ffunicode.c
Normal file
15593
software/sys_controller/fatfs/source/ffunicode.c
Normal file
File diff suppressed because it is too large
Load Diff
14
software/sys_controller/inc/file.h
Normal file
14
software/sys_controller/inc/file.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef FILE_H_
|
||||
#define FILE_H_
|
||||
|
||||
#include "ff.h"
|
||||
#include "sysconfig.h"
|
||||
|
||||
FRESULT file_mount();
|
||||
FRESULT file_open(FIL* fil, char* path);
|
||||
FRESULT file_close(FIL* fil);
|
||||
TCHAR* file_get_string(FIL* fil, char* buff, int len);
|
||||
FRESULT scan_files (char* path);
|
||||
int find_files_exec(char* path, char* pat, FILINFO *fno, int efirst, int elast, void (*func)(FILINFO *fno));
|
||||
|
||||
#endif
|
@ -20,6 +20,7 @@
|
||||
#ifndef FIRMWARE_H_
|
||||
#define FIRMWARE_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "alt_types.h"
|
||||
#include "sysconfig.h"
|
||||
|
||||
@ -40,23 +41,29 @@
|
||||
|
||||
#define FW_UPDATE_RETRIES 3
|
||||
|
||||
#define FW_IMAGE_ERROR 100
|
||||
#define FW_HDR_ERROR 101
|
||||
#define FW_HDR_CRC_ERROR 102
|
||||
#define FW_DATA_CRC_ERROR 103
|
||||
#define FW_UPD_CANCELLED 104
|
||||
|
||||
typedef struct {
|
||||
char fw_key[4];
|
||||
alt_u8 version_major;
|
||||
alt_u8 version_minor;
|
||||
uint8_t version_major;
|
||||
uint8_t version_minor;
|
||||
char version_suffix[8];
|
||||
alt_u32 hdr_len;
|
||||
alt_u32 data_len;
|
||||
alt_u32 data_crc;
|
||||
alt_u32 hdr_crc;
|
||||
} fw_hdr;
|
||||
uint32_t hdr_len;
|
||||
uint32_t data_len;
|
||||
uint32_t data_crc;
|
||||
char padding[482];
|
||||
uint32_t hdr_crc;
|
||||
} __attribute__((packed)) fw_hdr;
|
||||
|
||||
typedef struct {
|
||||
uint32_t unused[29];
|
||||
uint32_t reconfig_start;
|
||||
} rem_update_regs;
|
||||
|
||||
typedef struct {
|
||||
volatile rem_update_regs *regs;
|
||||
} rem_update_dev;
|
||||
|
||||
int fw_update();
|
||||
|
||||
void fw_update_commit(uint32_t* cluster_idx, uint8_t* databuf, uint32_t bytes_to_copy, uint16_t fs_csize, uint16_t fs_startsec);
|
||||
|
||||
#endif
|
||||
|
84
software/sys_controller/src/file.c
Normal file
84
software/sys_controller/src/file.c
Normal file
@ -0,0 +1,84 @@
|
||||
#include <stdio.h>
|
||||
#include "string.h"
|
||||
#include "file.h"
|
||||
|
||||
FATFS fs;
|
||||
|
||||
FRESULT file_mount()
|
||||
{
|
||||
return f_mount(&fs, "", 1);
|
||||
}
|
||||
|
||||
FRESULT file_open(FIL* fil, char* path)
|
||||
{
|
||||
return f_open(fil, path, FA_READ);
|
||||
}
|
||||
|
||||
TCHAR* file_get_string(FIL* fil, char* buff, int len)
|
||||
{
|
||||
return f_gets(buff, len, fil);
|
||||
}
|
||||
|
||||
FRESULT file_close(FIL* fil)
|
||||
{
|
||||
return f_close(fil);
|
||||
}
|
||||
|
||||
FRESULT scan_files (
|
||||
char* path /* Start node to be scanned (***also used as work area***) */
|
||||
)
|
||||
{
|
||||
FRESULT res;
|
||||
DIR dir;
|
||||
UINT i;
|
||||
static FILINFO fno;
|
||||
|
||||
|
||||
res = f_opendir(&dir, path); /* Open the directory */
|
||||
if (res == FR_OK) {
|
||||
for (;;) {
|
||||
res = f_readdir(&dir, &fno); /* Read a directory item */
|
||||
if (res != FR_OK || fno.fname[0] == 0) break; /* Break on error or end of dir */
|
||||
if (fno.fattrib & AM_DIR) { /* It is a directory */
|
||||
i = strlen(path);
|
||||
sprintf(&path[i], "/%s", fno.fname);
|
||||
res = scan_files(path); /* Enter the directory */
|
||||
if (res != FR_OK) break;
|
||||
path[i] = 0;
|
||||
} else { /* It is a file. */
|
||||
printf("%s/%s\n", path, fno.fname);
|
||||
}
|
||||
}
|
||||
f_closedir(&dir);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/* Find files (folders excluded) matching a pattern and execute function to a subset (efirst-elast) of matches. Stops on last match or elast, whichever comes first */
|
||||
int find_files_exec(char* path, char* pat, FILINFO *fno, int efirst, int elast, void (*func)(FILINFO *fno))
|
||||
{
|
||||
FRESULT fr; /* Return value */
|
||||
DIR dj; /* Directory object */
|
||||
int i = 0;
|
||||
|
||||
fr = f_findfirst(&dj, fno, path, pat); /* Start to search for photo files */
|
||||
|
||||
while (fr == FR_OK && fno->fname[0]) { /* Repeat while an item is found */
|
||||
if (!(fno->fattrib & AM_DIR)) {
|
||||
if ((i >= efirst) && (func != NULL))
|
||||
func(fno);
|
||||
if (++i > elast)
|
||||
break;
|
||||
}
|
||||
fr = f_findnext(&dj, fno); /* Search for next item */
|
||||
}
|
||||
|
||||
f_closedir(&dj);
|
||||
|
||||
//return fr;
|
||||
if (i <= efirst)
|
||||
return 0;
|
||||
else
|
||||
return i-efirst;
|
||||
}
|
@ -30,190 +30,223 @@
|
||||
#include "lcd.h"
|
||||
#include "utils.h"
|
||||
#include "menu.h"
|
||||
#include "ff.h"
|
||||
#include "file.h"
|
||||
#include "altera_avalon_pio_regs.h"
|
||||
|
||||
extern char menu_row1[LCD_ROW_LEN+1], menu_row2[LCD_ROW_LEN+1];
|
||||
extern alt_u16 rc_keymap[REMOTE_MAX_KEYS];
|
||||
extern SD_DEV sdcard_dev;
|
||||
extern alt_u32 sys_ctrl;
|
||||
extern flash_ctrl_dev flashctrl_dev;
|
||||
extern rem_update_dev rem_reconfig_dev;
|
||||
|
||||
static int check_fw_header(alt_u8 *databuf, fw_hdr *hdr)
|
||||
{
|
||||
alt_u32 crcval, tmp;
|
||||
|
||||
strncpy(hdr->fw_key, (char*)databuf, 4);
|
||||
if (strncmp(hdr->fw_key, "OSSC", 4))
|
||||
return FW_IMAGE_ERROR;
|
||||
|
||||
hdr->version_major = databuf[4];
|
||||
hdr->version_minor = databuf[5];
|
||||
strncpy(hdr->version_suffix, (char*)(databuf+6), 8);
|
||||
hdr->version_suffix[7] = 0;
|
||||
|
||||
memcpy(&tmp, databuf+14, 4);
|
||||
hdr->hdr_len = bswap32(tmp);
|
||||
memcpy(&tmp, databuf+18, 4);
|
||||
hdr->data_len = bswap32(tmp);
|
||||
memcpy(&tmp, databuf+22, 4);
|
||||
hdr->data_crc = bswap32(tmp);
|
||||
// Always at bytes [508-511]
|
||||
memcpy(&tmp, databuf+508, 4);
|
||||
hdr->hdr_crc = bswap32(tmp);
|
||||
|
||||
if (hdr->hdr_len < 26 || hdr->hdr_len > 508)
|
||||
return FW_HDR_ERROR;
|
||||
|
||||
crcval = crc32(databuf, hdr->hdr_len, 1);
|
||||
|
||||
if (crcval != hdr->hdr_crc)
|
||||
return FW_HDR_CRC_ERROR;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int check_fw_image(alt_u32 offset, alt_u32 size, alt_u32 golden_crc, alt_u8 *tmpbuf)
|
||||
{
|
||||
alt_u32 crcval=0, i, bytes_to_read;
|
||||
//int fw_update(char *dirname, char *filename) {
|
||||
int fw_update() {
|
||||
FIL fw_file;
|
||||
SDRESULTS res;
|
||||
char dirname_root[10];
|
||||
fw_hdr hdr;
|
||||
int retval;
|
||||
unsigned bytes_read, bytes_to_copy;
|
||||
uint32_t crcval, hdr_len, btn_vec;
|
||||
uint32_t cluster_idx[100]; // enough for >=4kB cluster size
|
||||
uint8_t databuf[SD_BLK_SIZE]; // temp buffer for data
|
||||
uint16_t fs_csize, fs_startsec, cl_iter, cl_soffs;
|
||||
|
||||
for (i=0; i<size; i=i+SD_BLK_SIZE) {
|
||||
bytes_to_read = ((size-i < SD_BLK_SIZE) ? (size-i) : SD_BLK_SIZE);
|
||||
res = SD_Read(&sdcard_dev, tmpbuf, (offset+i)/SD_BLK_SIZE, 0, bytes_to_read);
|
||||
|
||||
if (res != SD_OK)
|
||||
return -res;
|
||||
|
||||
crcval = crc32(tmpbuf, bytes_to_read, (i==0));
|
||||
}
|
||||
|
||||
if (crcval != golden_crc)
|
||||
return FW_DATA_CRC_ERROR;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fw_update()
|
||||
{
|
||||
int retval, i;
|
||||
int retries = FW_UPDATE_RETRIES;
|
||||
char *errmsg;
|
||||
alt_u8 databuf[SD_BLK_SIZE];
|
||||
alt_u32 btn_vec;
|
||||
alt_u32 bytes_to_rw;
|
||||
fw_hdr fw_header;
|
||||
|
||||
#ifdef CHECK_STACK_USE
|
||||
// estimate stack usage, assuming around here is the worst case (due to 512B databuf)
|
||||
alt_u32 sp;
|
||||
asm volatile("mv %0, sp" : "=r"(sp));
|
||||
sniprintf(menu_row1, LCD_ROW_LEN+1, "Stack size:");
|
||||
sniprintf(menu_row2, LCD_ROW_LEN+1, "%lu bytes", (ONCHIP_MEMORY2_0_BASE+ONCHIP_MEMORY2_0_SIZE_VALUE)-sp);
|
||||
ui_disp_menu(1);
|
||||
usleep(1000000);
|
||||
#endif
|
||||
|
||||
retval = check_sdcard(databuf);
|
||||
SPI_CS_High();
|
||||
retval = file_mount();
|
||||
if (retval != 0) {
|
||||
retval = -retval;
|
||||
goto failure;
|
||||
printf("SD card not detected %d\n", retval);
|
||||
return -1;
|
||||
}
|
||||
|
||||
retval = check_fw_header(databuf, &fw_header);
|
||||
if (retval != 0)
|
||||
goto failure;
|
||||
//sniprintf(dirname_root, sizeof(dirname_root), "/%s", dirname);
|
||||
sniprintf(dirname_root, sizeof(dirname_root), "/");
|
||||
f_chdir(dirname_root);
|
||||
|
||||
sniprintf(menu_row1, LCD_ROW_LEN+1, "Validating data");
|
||||
sniprintf(menu_row2, LCD_ROW_LEN+1, "%u bytes", (unsigned)fw_header.data_len);
|
||||
ui_disp_menu(1);
|
||||
retval = check_fw_image(512, fw_header.data_len, fw_header.data_crc, databuf);
|
||||
if (retval != 0)
|
||||
goto failure;
|
||||
if (!file_open(&fw_file, "ossc.bin")) {
|
||||
strlcpy(menu_row1, "Checking FW", LCD_ROW_LEN+1);
|
||||
strlcpy(menu_row2, "Please wait...", LCD_ROW_LEN+1);
|
||||
ui_disp_menu(1);
|
||||
|
||||
sniprintf(menu_row1, LCD_ROW_LEN+1, "%u.%.2u%s%s", fw_header.version_major, fw_header.version_minor, (fw_header.version_suffix[0] == 0) ? "" : "-", fw_header.version_suffix);
|
||||
strncpy(menu_row2, "Update? 1=Y, 2=N", LCD_ROW_LEN+1);
|
||||
ui_disp_menu(1);
|
||||
|
||||
while (1) {
|
||||
btn_vec = IORD_ALTERA_AVALON_PIO_DATA(PIO_1_BASE) & RC_MASK;
|
||||
|
||||
if (btn_vec == rc_keymap[RC_BTN1]) {
|
||||
break;
|
||||
} else if (btn_vec == rc_keymap[RC_BTN2]) {
|
||||
retval = FW_UPD_CANCELLED;
|
||||
goto failure;
|
||||
if (f_read(&fw_file, &hdr, sizeof(hdr), &bytes_read) != F_OK) {
|
||||
printf("FW hdr read error\n");
|
||||
retval = -3;
|
||||
goto close_file;
|
||||
}
|
||||
|
||||
usleep(WAITLOOP_SLEEP_US);
|
||||
hdr_len = bswap32(hdr.hdr_len);
|
||||
|
||||
if (strncmp(hdr.fw_key, "OSSC", 4) || (hdr_len < 26 || hdr_len > 508)) {
|
||||
printf("Invalid FW header\n");
|
||||
retval = -4;
|
||||
goto close_file;
|
||||
}
|
||||
|
||||
crcval = crc32((unsigned char *)&hdr, hdr_len, 1);
|
||||
hdr.hdr_len = bswap32(hdr.hdr_len);
|
||||
hdr.data_len = bswap32(hdr.data_len);
|
||||
hdr.data_crc = bswap32(hdr.data_crc);
|
||||
hdr.hdr_crc = bswap32(hdr.hdr_crc);
|
||||
if (crcval != hdr.hdr_crc) {
|
||||
printf("Invalid FW header CRC (0x%.8x instead of 0x%.8x)\n", crcval, hdr.hdr_crc);
|
||||
retval = -5;
|
||||
goto close_file;
|
||||
}
|
||||
|
||||
printf("Firmware %u.%u%s%s\n", hdr.version_major, hdr.version_minor, hdr.version_suffix[0] ? "-" : "", hdr.version_suffix);
|
||||
bytes_to_copy = hdr.data_len;
|
||||
printf(" Image: %u bytes, crc 0x%.8x\n", hdr.data_len, hdr.data_crc);
|
||||
if (hdr.data_len >= 16*FLASH_SECTOR_SIZE) {
|
||||
printf("Image exceeds flash allocation\n");
|
||||
retval = -6;
|
||||
goto close_file;
|
||||
}
|
||||
|
||||
sniprintf(menu_row1, LCD_ROW_LEN+1, "v%u.%u%s%s", hdr.version_major, hdr.version_minor, hdr.version_suffix[0] ? "-" : "", hdr.version_suffix);
|
||||
sniprintf(menu_row2, LCD_ROW_LEN+1, "Update? 1=Y, 2=N");
|
||||
ui_disp_menu(1);
|
||||
|
||||
while (1) {
|
||||
btn_vec = IORD_ALTERA_AVALON_PIO_DATA(PIO_1_BASE) & RC_MASK;
|
||||
|
||||
if (btn_vec == rc_keymap[RC_BTN1]) {
|
||||
break;
|
||||
} else if (btn_vec == rc_keymap[RC_BTN2]) {
|
||||
//set_func_ret_msg("Cancelled");
|
||||
retval = 1;
|
||||
goto close_file;
|
||||
}
|
||||
|
||||
usleep(WAITLOOP_SLEEP_US);
|
||||
}
|
||||
|
||||
strlcpy(menu_row2, "Please wait...", LCD_ROW_LEN+1);
|
||||
ui_disp_menu(1);
|
||||
|
||||
// check if 512-byte header is on first or second cluster
|
||||
fs_startsec = fw_file.obj.fs->database;
|
||||
fs_csize = fw_file.obj.fs->csize;
|
||||
if (fs_csize == 1) {
|
||||
cl_iter = 1;
|
||||
cl_soffs = 0;
|
||||
cluster_idx[0] = fw_file.obj.sclust;
|
||||
} else {
|
||||
cl_iter = 0;
|
||||
cl_soffs = 1;
|
||||
}
|
||||
// record cluster IDs to an array
|
||||
if ((f_read_cc(&fw_file, &cluster_idx[cl_iter], bytes_to_copy, &bytes_read, (sizeof(cluster_idx)/sizeof(cluster_idx[0]))-1) != F_OK) || (bytes_read != bytes_to_copy)) {
|
||||
printf("FW cluster error\n");
|
||||
retval = -7;
|
||||
goto close_file;
|
||||
}
|
||||
|
||||
file_close(&fw_file);
|
||||
f_chdir("/");
|
||||
|
||||
printf("Checking copied data...\n");
|
||||
while (bytes_to_copy > 0) {
|
||||
bytes_read = (bytes_to_copy > SD_BLK_SIZE) ? SD_BLK_SIZE : bytes_to_copy;
|
||||
res = SD_Read(&sdcard_dev, databuf, ((cluster_idx[cl_iter]-2)*fs_csize+fs_startsec+cl_soffs), 0, bytes_read);
|
||||
if (res != SD_OK) {
|
||||
printf("FW data read error\n");
|
||||
retval = -8;
|
||||
goto close_file;
|
||||
}
|
||||
|
||||
crcval = crc32((unsigned char *)&databuf, bytes_read, (bytes_to_copy==hdr.data_len));
|
||||
bytes_to_copy -= bytes_read;
|
||||
|
||||
cl_soffs += 1;
|
||||
if (cl_soffs == fs_csize) {
|
||||
cl_iter += 1;
|
||||
cl_soffs = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (crcval != hdr.data_crc) {
|
||||
printf("Image: Invalid CRC (0x%.8x)\n", crcval);
|
||||
retval = -9;
|
||||
goto close_file;
|
||||
}
|
||||
|
||||
printf("Starting update procedure...\n");
|
||||
strlcpy(menu_row1, "Updating", LCD_ROW_LEN+1);
|
||||
ui_disp_menu(1);
|
||||
|
||||
//disable video output
|
||||
tvp_powerdown();
|
||||
sys_ctrl |= VIDGEN_OFF;
|
||||
IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl);
|
||||
usleep(10000);
|
||||
|
||||
// No return from here
|
||||
fw_update_commit(cluster_idx, databuf, hdr.data_len, fs_csize, fs_startsec);
|
||||
return 0;
|
||||
} else {
|
||||
printf("FW file not found\n");
|
||||
f_chdir("/");
|
||||
return -2;
|
||||
}
|
||||
|
||||
//disable video output
|
||||
tvp_powerdown();
|
||||
sys_ctrl |= VIDGEN_OFF;
|
||||
IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl);
|
||||
usleep(10000);
|
||||
|
||||
strncpy(menu_row1, "Updating FW", LCD_ROW_LEN+1);
|
||||
update_init:
|
||||
strncpy(menu_row2, "please wait...", LCD_ROW_LEN+1);
|
||||
ui_disp_menu(1);
|
||||
|
||||
/*retval = copy_sd_to_flash(512/SD_BLK_SIZE, 0, fw_header.data_len, databuf);
|
||||
if (retval != 0)
|
||||
goto failure;
|
||||
|
||||
strncpy(menu_row1, "Verifying flash", LCD_ROW_LEN+1);
|
||||
ui_disp_menu(1);
|
||||
retval = verify_flash(0, fw_header.data_len, fw_header.data_crc, databuf);
|
||||
if (retval != 0)
|
||||
goto failure;*/
|
||||
|
||||
SPI_CS_High();
|
||||
|
||||
strncpy(menu_row1, "Firmware updated", LCD_ROW_LEN+1);
|
||||
strncpy(menu_row2, "please restart", LCD_ROW_LEN+1);
|
||||
ui_disp_menu(1);
|
||||
while (1) {}
|
||||
|
||||
return 0;
|
||||
|
||||
failure:
|
||||
SPI_CS_High();
|
||||
|
||||
switch (retval) {
|
||||
case SD_NOINIT:
|
||||
errmsg = "No SD card det.";
|
||||
break;
|
||||
case FW_IMAGE_ERROR:
|
||||
errmsg = "Invalid image";
|
||||
break;
|
||||
case FW_HDR_ERROR:
|
||||
errmsg = "Invalid header";
|
||||
break;
|
||||
case FW_HDR_CRC_ERROR:
|
||||
errmsg = "Invalid hdr CRC";
|
||||
break;
|
||||
case FW_DATA_CRC_ERROR:
|
||||
errmsg = "Invalid data CRC";
|
||||
break;
|
||||
case FW_UPD_CANCELLED:
|
||||
errmsg = "Update cancelled";
|
||||
break;
|
||||
default:
|
||||
errmsg = "SD/Flash error";
|
||||
break;
|
||||
}
|
||||
strncpy(menu_row2, errmsg, LCD_ROW_LEN+1);
|
||||
ui_disp_menu(1);
|
||||
usleep(1000000);
|
||||
|
||||
// Critical error, retry update
|
||||
if ((retval < 0) && (retries > 0)) {
|
||||
sniprintf(menu_row1, LCD_ROW_LEN+1, "Retrying update");
|
||||
retries--;
|
||||
goto update_init;
|
||||
}
|
||||
|
||||
render_osd_page();
|
||||
return -1;
|
||||
close_file:
|
||||
file_close(&fw_file);
|
||||
f_chdir("/");
|
||||
return retval;
|
||||
}
|
||||
|
||||
// commit FW update. Do not call functions located in flash during update
|
||||
void __attribute__((noinline, flatten, noreturn, __section__(".text_bram"))) fw_update_commit(uint32_t* cluster_idx, uint8_t* databuf, uint32_t bytes_to_copy, uint16_t fs_csize, uint16_t fs_startsec) {
|
||||
int i, sectors;
|
||||
SDRESULTS res;
|
||||
uint16_t cl_iter, cl_soffs;
|
||||
uint32_t addr, bytes_read;
|
||||
uint32_t *data_to;
|
||||
|
||||
flash_write_protect(&flashctrl_dev, 0);
|
||||
|
||||
// Erase sectors
|
||||
addr = 0;
|
||||
sectors = (bytes_to_copy/FLASH_SECTOR_SIZE) + ((bytes_to_copy % FLASH_SECTOR_SIZE) != 0);
|
||||
data_to = (uint32_t*)(INTEL_GENERIC_SERIAL_FLASH_INTERFACE_TOP_0_AVL_MEM_BASE);
|
||||
|
||||
for (i=0; i<sectors; i++) {
|
||||
flash_sector_erase(&flashctrl_dev, addr);
|
||||
addr += FLASH_SECTOR_SIZE;
|
||||
}
|
||||
|
||||
if (fs_csize == 1) {
|
||||
cl_iter = 1;
|
||||
cl_soffs = 0;
|
||||
} else {
|
||||
cl_iter = 0;
|
||||
cl_soffs = 1;
|
||||
}
|
||||
|
||||
// Write data
|
||||
while (bytes_to_copy > 0) {
|
||||
bytes_read = (bytes_to_copy > SD_BLK_SIZE) ? SD_BLK_SIZE : bytes_to_copy;
|
||||
res = SD_Read(&sdcard_dev, databuf, ((cluster_idx[cl_iter]-2)*fs_csize+fs_startsec+cl_soffs), 0, bytes_read);
|
||||
//TODO: retry if read fails
|
||||
|
||||
bytes_to_copy -= bytes_read;
|
||||
for (i=0; i<bytes_read; i++)
|
||||
databuf[i] = bitswap8(databuf[i]);
|
||||
for (i=0; i<bytes_read; i+=4)
|
||||
*data_to++ = *((uint32_t*)&databuf[i]);
|
||||
|
||||
cl_soffs += 1;
|
||||
if (cl_soffs == fs_csize) {
|
||||
cl_iter += 1;
|
||||
cl_soffs = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// flush command FIFO before FPGA reconfiguration start
|
||||
*(volatile uint32_t*)(INTEL_GENERIC_SERIAL_FLASH_INTERFACE_TOP_0_AVL_MEM_BASE);
|
||||
|
||||
rem_reconfig_dev.regs->reconfig_start = 1;
|
||||
|
||||
while (1) {}
|
||||
}
|
||||
|
@ -208,9 +208,7 @@ MENU(menu_scanlines, P99_PROTECT({ \
|
||||
{ "Sl. alternating", OPT_AVCONFIG_SELECTION, { .sel = { &tc.sl_altern, OPT_WRAP, SETTING_ITEM(off_on_desc) } } },
|
||||
{ LNG("Sl. alignment","スキャンラインポジション"), OPT_AVCONFIG_SELECTION, { .sel = { &tc.sl_id, OPT_WRAP, SETTING_ITEM(sl_id_desc) } } },
|
||||
{ LNG("Sl. type","スキャンラインルイ"), OPT_AVCONFIG_SELECTION, { .sel = { &tc.sl_type, OPT_WRAP, SETTING_ITEM(sl_type_desc) } } },
|
||||
#ifndef DEBUG
|
||||
{ "< Custom Sl. >", OPT_SUBMENU, { .sub = { &menu_cust_sl, NULL, NULL } } },
|
||||
#endif
|
||||
}))
|
||||
|
||||
MENU(menu_postproc, P99_PROTECT({ \
|
||||
@ -251,11 +249,9 @@ MENU(menu_settings, P99_PROTECT({ \
|
||||
{ LNG("<Load profile >","<プロファイルロード >"), OPT_FUNC_CALL, { .fun = { load_profile, &profile_arg_info } } },
|
||||
{ LNG("<Save profile >","<プロファイルセーブ >"), OPT_FUNC_CALL, { .fun = { save_profile, &profile_arg_info } } },
|
||||
{ LNG("<Reset settings>","<セッテイヲショキカ >"), OPT_FUNC_CALL, { .fun = { set_default_avconfig, NULL } } },
|
||||
#ifndef DEBUG
|
||||
{ LNG("<Import sett. >","<セッテイヨミコミ >"), OPT_FUNC_CALL, { .fun = { import_userdata, NULL } } },
|
||||
{ LNG("<Export sett. >","<セッテイカキコミ >"), OPT_FUNC_CALL, { .fun = { export_userdata, NULL } } },
|
||||
{ LNG("<Fw. update >","<ファームウェアアップデート>"), OPT_FUNC_CALL, { .fun = { fw_update, NULL } } },
|
||||
#endif
|
||||
}))
|
||||
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "sysconfig.h"
|
||||
#include "io.h"
|
||||
|
||||
inline unsigned char bitswap8(unsigned char v)
|
||||
inline __attribute__((flatten, __section__(".text_bram"))) unsigned char bitswap8(unsigned char v)
|
||||
{
|
||||
return ((v * 0x0802LU & 0x22110LU) |
|
||||
(v * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16;
|
||||
|
@ -94,11 +94,11 @@ DWORD __SD_Power_Of_Two(BYTE e)
|
||||
return(partial);
|
||||
}
|
||||
|
||||
inline void __SD_Assert(void){
|
||||
inline void __attribute__((flatten, __section__(".text_bram"))) __SD_Assert(void){
|
||||
SPI_CS_Low();
|
||||
}
|
||||
|
||||
inline void __SD_Deassert(void){
|
||||
inline void __attribute__((flatten, __section__(".text_bram"))) __SD_Deassert(void){
|
||||
SPI_CS_High();
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ void __SD_Speed_Transfer(BYTE throttle) {
|
||||
else SPI_Freq_Low();
|
||||
}
|
||||
|
||||
BYTE __SD_Send_Cmd(BYTE cmd, DWORD arg)
|
||||
BYTE __attribute__((noinline, flatten, __section__(".text_bram"))) __SD_Send_Cmd(BYTE cmd, DWORD arg)
|
||||
{
|
||||
BYTE wiredata[10];
|
||||
BYTE crc, res;
|
||||
@ -361,7 +361,7 @@ SDRESULTS SD_Init(SD_DEV *dev)
|
||||
#endif
|
||||
}
|
||||
|
||||
SDRESULTS SD_Read(SD_DEV *dev, void *dat, DWORD sector, WORD ofs, WORD cnt)
|
||||
SDRESULTS __attribute__((noinline, flatten, __section__(".text_bram"))) SD_Read(SD_DEV *dev, void *dat, DWORD sector, WORD ofs, WORD cnt)
|
||||
{
|
||||
#if defined(_M_IX86) // x86
|
||||
// Check the sector query
|
||||
|
@ -15,11 +15,11 @@ void SPI_Init (void) {
|
||||
I2C_init(SD_SPI_BASE,ALT_CPU_FREQ,400000);
|
||||
}
|
||||
|
||||
void SPI_W(const BYTE *wd, int len) {
|
||||
void __attribute__((noinline, flatten, __section__(".text_bram"))) SPI_W(const BYTE *wd, int len) {
|
||||
SPI_write(SD_SPI_BASE, wd, len);
|
||||
}
|
||||
|
||||
void SPI_R(BYTE *rd, int len) {
|
||||
void __attribute__((noinline, flatten, __section__(".text_bram"))) SPI_R(BYTE *rd, int len) {
|
||||
SPI_read(SD_SPI_BASE, rd, len);
|
||||
}
|
||||
|
||||
@ -34,16 +34,17 @@ BYTE SPI_RW (BYTE d) {
|
||||
return w;
|
||||
}
|
||||
|
||||
void SPI_Release (void) {
|
||||
void __attribute__((noinline, flatten, __section__(".text_bram"))) SPI_Release (void) {
|
||||
SPI_CS_High();
|
||||
return;
|
||||
}
|
||||
|
||||
inline void SPI_CS_Low (void) {
|
||||
inline void __attribute__((flatten, __section__(".text_bram"))) SPI_CS_Low (void) {
|
||||
sys_ctrl &= ~SD_SPI_SS_N;
|
||||
IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl);
|
||||
}
|
||||
|
||||
inline void SPI_CS_High (void){
|
||||
inline void __attribute__((flatten, __section__(".text_bram"))) SPI_CS_High (void){
|
||||
sys_ctrl |= SD_SPI_SS_N;
|
||||
IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl);
|
||||
}
|
||||
@ -56,7 +57,7 @@ inline void SPI_Freq_Low (void) {
|
||||
I2C_init(SD_SPI_BASE,ALT_CPU_FREQ,400000);
|
||||
}
|
||||
|
||||
int SPI_Timer_On (WORD ms) {
|
||||
int __attribute__((noinline, flatten, __section__(".text_bram"))) SPI_Timer_On (WORD ms) {
|
||||
if (!sd_timer_ts) {
|
||||
sd_timer_ts = alt_timestamp() + ms*(TIMER_0_FREQ/1000);
|
||||
return 0;
|
||||
@ -64,11 +65,11 @@ int SPI_Timer_On (WORD ms) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline BOOL SPI_Timer_Status (void) {
|
||||
inline BOOL __attribute__((flatten, __section__(".text_bram"))) SPI_Timer_Status (void) {
|
||||
return alt_timestamp() < sd_timer_ts;
|
||||
}
|
||||
|
||||
inline void SPI_Timer_Off (void) {
|
||||
inline void __attribute__((flatten, __section__(".text_bram"))) SPI_Timer_Off (void) {
|
||||
sd_timer_ts = 0;
|
||||
return;
|
||||
}
|
||||
|
55
sys.qsys
55
sys.qsys
@ -293,6 +293,27 @@
|
||||
type = "int";
|
||||
}
|
||||
}
|
||||
element remote_update_0
|
||||
{
|
||||
datum _sortIndex
|
||||
{
|
||||
value = "16";
|
||||
type = "int";
|
||||
}
|
||||
}
|
||||
element remote_update_0.avl_csr
|
||||
{
|
||||
datum _lockedAddress
|
||||
{
|
||||
value = "1";
|
||||
type = "boolean";
|
||||
}
|
||||
datum baseAddress
|
||||
{
|
||||
value = "172032";
|
||||
type = "String";
|
||||
}
|
||||
}
|
||||
element sc_config_0
|
||||
{
|
||||
datum _sortIndex
|
||||
@ -578,6 +599,21 @@
|
||||
<parameter name="SYNCHRONOUS_EDGES" value="deassert" />
|
||||
<parameter name="USE_RESET_REQUEST" value="0" />
|
||||
</module>
|
||||
<module
|
||||
name="remote_update_0"
|
||||
kind="altera_remote_update"
|
||||
version="24.1"
|
||||
enabled="1">
|
||||
<parameter name="AUTO_DEVICE_SPEEDGRADE" value="8" />
|
||||
<parameter name="CBX_AUTO_BLACKBOX" value="ALL" />
|
||||
<parameter name="DEVICE" value="EP4CE15E22C8" />
|
||||
<parameter name="DEVICE_FAMILY" value="Cyclone IV E" />
|
||||
<parameter name="GUI_config_device" value="EPCS16" />
|
||||
<parameter name="check_app_pof" value="false" />
|
||||
<parameter name="check_avalon_interface" value="true" />
|
||||
<parameter name="m_support_write_config_check" value="false" />
|
||||
<parameter name="operation_mode" value="REMOTE" />
|
||||
</module>
|
||||
<module name="sc_config_0" kind="sc_config" version="1.0" enabled="1" />
|
||||
<module name="timer_0" kind="altera_avalon_timer" version="24.1" enabled="1">
|
||||
<parameter name="alwaysRun" value="false" />
|
||||
@ -672,6 +708,15 @@
|
||||
<parameter name="baseAddress" value="0x00020100" />
|
||||
<parameter name="defaultConnection" value="false" />
|
||||
</connection>
|
||||
<connection
|
||||
kind="avalon"
|
||||
version="24.1"
|
||||
start="ibex_0.avalon_master_bus_data"
|
||||
end="remote_update_0.avl_csr">
|
||||
<parameter name="arbitrationPriority" value="1" />
|
||||
<parameter name="baseAddress" value="0x0002a000" />
|
||||
<parameter name="defaultConnection" value="false" />
|
||||
</connection>
|
||||
<connection
|
||||
kind="avalon"
|
||||
version="24.1"
|
||||
@ -816,6 +861,11 @@
|
||||
version="24.1"
|
||||
start="clk_27.clk"
|
||||
end="i2c_opencores_1.clock" />
|
||||
<connection
|
||||
kind="clock"
|
||||
version="24.1"
|
||||
start="clk_27.clk"
|
||||
end="remote_update_0.clock" />
|
||||
<connection
|
||||
kind="clock"
|
||||
version="24.1"
|
||||
@ -894,6 +944,11 @@
|
||||
version="24.1"
|
||||
start="clk_27.clk_reset"
|
||||
end="intel_generic_serial_flash_interface_top_0.reset" />
|
||||
<connection
|
||||
kind="reset"
|
||||
version="24.1"
|
||||
start="clk_27.clk_reset"
|
||||
end="remote_update_0.reset" />
|
||||
<connection
|
||||
kind="reset"
|
||||
version="24.1"
|
||||
|
741
sys.sopcinfo
741
sys.sopcinfo
@ -1,11 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<EnsembleReport name="sys" kind="sys" version="1.0" fabric="QSYS">
|
||||
<!-- Format version 24.1 1077 (Future versions may contain additional information.) -->
|
||||
<!-- 2025.04.18.22:02:06 -->
|
||||
<!-- 2025.05.03.12:04:14 -->
|
||||
<!-- A collection of modules and connections -->
|
||||
<parameter name="AUTO_GENERATION_ID">
|
||||
<type>java.lang.Integer</type>
|
||||
<value>1745002926</value>
|
||||
<value>1746263054</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>false</visible>
|
||||
@ -402,6 +402,12 @@ parameters are a RESULT of the module parameters. -->
|
||||
<slaveName>clock</slaveName>
|
||||
<name>i2c_opencores_1.clock</name>
|
||||
</clockDomainMember>
|
||||
<clockDomainMember>
|
||||
<isBridge>false</isBridge>
|
||||
<moduleName>remote_update_0</moduleName>
|
||||
<slaveName>clock</slaveName>
|
||||
<name>remote_update_0.clock</name>
|
||||
</clockDomainMember>
|
||||
<clockDomainMember>
|
||||
<isBridge>false</isBridge>
|
||||
<moduleName>sc_config_0</moduleName>
|
||||
@ -3314,6 +3320,14 @@ parameters are a RESULT of the module parameters. -->
|
||||
<baseAddress>131328</baseAddress>
|
||||
<span>256</span>
|
||||
</memoryBlock>
|
||||
<memoryBlock>
|
||||
<isBridge>false</isBridge>
|
||||
<moduleName>remote_update_0</moduleName>
|
||||
<slaveName>avl_csr</slaveName>
|
||||
<name>remote_update_0.avl_csr</name>
|
||||
<baseAddress>172032</baseAddress>
|
||||
<span>128</span>
|
||||
</memoryBlock>
|
||||
<memoryBlock>
|
||||
<isBridge>false</isBridge>
|
||||
<moduleName>intel_generic_serial_flash_interface_top_0</moduleName>
|
||||
@ -10799,6 +10813,604 @@ parameters are a RESULT of the module parameters. -->
|
||||
</port>
|
||||
</interface>
|
||||
</module>
|
||||
<module
|
||||
name="remote_update_0"
|
||||
kind="altera_remote_update"
|
||||
version="24.1"
|
||||
path="remote_update_0">
|
||||
<!-- Describes a single module. Module parameters are
|
||||
the requested settings for a module instance. -->
|
||||
<parameter name="DEVICE_FAMILY">
|
||||
<type>java.lang.String</type>
|
||||
<value>CYCLONEIVE</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>false</visible>
|
||||
<valid>true</valid>
|
||||
<sysinfo_type>DEVICE_FAMILY</sysinfo_type>
|
||||
</parameter>
|
||||
<parameter name="DEVICE">
|
||||
<type>java.lang.String</type>
|
||||
<value>EP4CE15E22C8</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>false</visible>
|
||||
<valid>true</valid>
|
||||
<sysinfo_type>DEVICE</sysinfo_type>
|
||||
</parameter>
|
||||
<parameter name="CBX_AUTO_BLACKBOX">
|
||||
<type>java.lang.String</type>
|
||||
<value>ALL</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>false</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="operation_mode">
|
||||
<type>java.lang.String</type>
|
||||
<value>REMOTE</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="GUI_config_device">
|
||||
<type>java.lang.String</type>
|
||||
<value>EPCS16</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="m_support_write_config_check">
|
||||
<type>boolean</type>
|
||||
<value>false</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="check_avalon_interface">
|
||||
<type>boolean</type>
|
||||
<value>true</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="check_app_pof">
|
||||
<type>boolean</type>
|
||||
<value>false</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="config_device_addr_width">
|
||||
<type>int</type>
|
||||
<value>24</value>
|
||||
<derived>true</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>false</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="is_epcq">
|
||||
<type>boolean</type>
|
||||
<value>false</value>
|
||||
<derived>true</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>false</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="in_data_width">
|
||||
<type>int</type>
|
||||
<value>24</value>
|
||||
<derived>true</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>false</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="out_data_width">
|
||||
<type>int</type>
|
||||
<value>24</value>
|
||||
<derived>true</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>false</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="AUTO_DEVICE_SPEEDGRADE">
|
||||
<type>java.lang.String</type>
|
||||
<value>8</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>false</visible>
|
||||
<valid>true</valid>
|
||||
<sysinfo_type>DEVICE_SPEEDGRADE</sysinfo_type>
|
||||
</parameter>
|
||||
<parameter name="deviceFamily">
|
||||
<type>java.lang.String</type>
|
||||
<value>UNKNOWN</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="generateLegacySim">
|
||||
<type>boolean</type>
|
||||
<value>false</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<interface name="avl_csr" kind="avalon_slave" version="24.1">
|
||||
<!-- The connection points exposed by a module instance for the
|
||||
particular module parameters. Connection points and their
|
||||
parameters are a RESULT of the module parameters. -->
|
||||
<assignment>
|
||||
<name>embeddedsw.configuration.isFlash</name>
|
||||
<value>0</value>
|
||||
</assignment>
|
||||
<assignment>
|
||||
<name>embeddedsw.configuration.isMemoryDevice</name>
|
||||
<value>0</value>
|
||||
</assignment>
|
||||
<assignment>
|
||||
<name>embeddedsw.configuration.isNonVolatileStorage</name>
|
||||
<value>0</value>
|
||||
</assignment>
|
||||
<assignment>
|
||||
<name>embeddedsw.configuration.isPrintableDevice</name>
|
||||
<value>0</value>
|
||||
</assignment>
|
||||
<parameter name="addressAlignment">
|
||||
<type>com.altera.sopcmodel.avalon.AvalonConnectionPoint$AddressAlignment</type>
|
||||
<value>DYNAMIC</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>false</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="addressGroup">
|
||||
<type>int</type>
|
||||
<value>0</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>false</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="addressSpan">
|
||||
<type>java.math.BigInteger</type>
|
||||
<value>128</value>
|
||||
<derived>true</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>false</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="addressUnits">
|
||||
<type>com.altera.sopcmodel.avalon.EAddrBurstUnits</type>
|
||||
<value>WORDS</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="alwaysBurstMaxBurst">
|
||||
<type>boolean</type>
|
||||
<value>false</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>false</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="associatedClock">
|
||||
<type>java.lang.String</type>
|
||||
<value>clock</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="associatedReset">
|
||||
<type>java.lang.String</type>
|
||||
<value>reset</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="bitsPerSymbol">
|
||||
<type>int</type>
|
||||
<value>8</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="bridgedAddressOffset">
|
||||
<type>java.math.BigInteger</type>
|
||||
<value>0</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>false</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="bridgesToMaster">
|
||||
<type>com.altera.entityinterfaces.IConnectionPoint</type>
|
||||
<value></value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>false</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="burstOnBurstBoundariesOnly">
|
||||
<type>boolean</type>
|
||||
<value>false</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="burstcountUnits">
|
||||
<type>com.altera.sopcmodel.avalon.EAddrBurstUnits</type>
|
||||
<value>WORDS</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="constantBurstBehavior">
|
||||
<type>boolean</type>
|
||||
<value>false</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>false</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="explicitAddressSpan">
|
||||
<type>java.math.BigInteger</type>
|
||||
<value>0</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="holdTime">
|
||||
<type>int</type>
|
||||
<value>0</value>
|
||||
<derived>false</derived>
|
||||
<enabled>false</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="interleaveBursts">
|
||||
<type>boolean</type>
|
||||
<value>false</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>false</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="isBigEndian">
|
||||
<type>boolean</type>
|
||||
<value>false</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>false</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="isFlash">
|
||||
<type>boolean</type>
|
||||
<value>false</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>false</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="isMemoryDevice">
|
||||
<type>boolean</type>
|
||||
<value>false</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>false</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="isNonVolatileStorage">
|
||||
<type>boolean</type>
|
||||
<value>false</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>false</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="linewrapBursts">
|
||||
<type>boolean</type>
|
||||
<value>false</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="maximumPendingReadTransactions">
|
||||
<type>int</type>
|
||||
<value>1</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="maximumPendingWriteTransactions">
|
||||
<type>int</type>
|
||||
<value>0</value>
|
||||
<derived>false</derived>
|
||||
<enabled>false</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="minimumUninterruptedRunLength">
|
||||
<type>int</type>
|
||||
<value>1</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>false</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="printableDevice">
|
||||
<type>boolean</type>
|
||||
<value>false</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>false</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="readLatency">
|
||||
<type>int</type>
|
||||
<value>0</value>
|
||||
<derived>false</derived>
|
||||
<enabled>false</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="readWaitStates">
|
||||
<type>int</type>
|
||||
<value>1</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>false</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="readWaitTime">
|
||||
<type>int</type>
|
||||
<value>1</value>
|
||||
<derived>false</derived>
|
||||
<enabled>false</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="registerIncomingSignals">
|
||||
<type>boolean</type>
|
||||
<value>false</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>false</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="registerOutgoingSignals">
|
||||
<type>boolean</type>
|
||||
<value>false</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>false</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="setupTime">
|
||||
<type>int</type>
|
||||
<value>0</value>
|
||||
<derived>false</derived>
|
||||
<enabled>false</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="timingUnits">
|
||||
<type>com.altera.sopcmodel.avalon.TimingUnits</type>
|
||||
<value>Cycles</value>
|
||||
<derived>false</derived>
|
||||
<enabled>false</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="transparentBridge">
|
||||
<type>boolean</type>
|
||||
<value>false</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>false</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="wellBehavedWaitrequest">
|
||||
<type>boolean</type>
|
||||
<value>false</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>false</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="writeLatency">
|
||||
<type>int</type>
|
||||
<value>0</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>false</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="writeWaitStates">
|
||||
<type>int</type>
|
||||
<value>0</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>false</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="writeWaitTime">
|
||||
<type>int</type>
|
||||
<value>0</value>
|
||||
<derived>false</derived>
|
||||
<enabled>false</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="deviceFamily">
|
||||
<type>java.lang.String</type>
|
||||
<value>UNKNOWN</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="generateLegacySim">
|
||||
<type>boolean</type>
|
||||
<value>false</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<type>avalon</type>
|
||||
<isStart>false</isStart>
|
||||
<port>
|
||||
<name>avl_csr_write</name>
|
||||
<direction>Input</direction>
|
||||
<width>1</width>
|
||||
<role>write</role>
|
||||
</port>
|
||||
<port>
|
||||
<name>avl_csr_read</name>
|
||||
<direction>Input</direction>
|
||||
<width>1</width>
|
||||
<role>read</role>
|
||||
</port>
|
||||
<port>
|
||||
<name>avl_csr_writedata</name>
|
||||
<direction>Input</direction>
|
||||
<width>32</width>
|
||||
<role>writedata</role>
|
||||
</port>
|
||||
<port>
|
||||
<name>avl_csr_readdata</name>
|
||||
<direction>Output</direction>
|
||||
<width>32</width>
|
||||
<role>readdata</role>
|
||||
</port>
|
||||
<port>
|
||||
<name>avl_csr_readdatavalid</name>
|
||||
<direction>Output</direction>
|
||||
<width>1</width>
|
||||
<role>readdatavalid</role>
|
||||
</port>
|
||||
<port>
|
||||
<name>avl_csr_waitrequest</name>
|
||||
<direction>Output</direction>
|
||||
<width>1</width>
|
||||
<role>waitrequest</role>
|
||||
</port>
|
||||
<port>
|
||||
<name>avl_csr_address</name>
|
||||
<direction>Input</direction>
|
||||
<width>5</width>
|
||||
<role>address</role>
|
||||
</port>
|
||||
</interface>
|
||||
<interface name="clock" kind="clock_sink" version="24.1">
|
||||
<!-- The connection points exposed by a module instance for the
|
||||
particular module parameters. Connection points and their
|
||||
parameters are a RESULT of the module parameters. -->
|
||||
<parameter name="externallyDriven">
|
||||
<type>boolean</type>
|
||||
<value>false</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>false</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="ptfSchematicName">
|
||||
<type>java.lang.String</type>
|
||||
<value></value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>false</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="deviceFamily">
|
||||
<type>java.lang.String</type>
|
||||
<value>UNKNOWN</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="generateLegacySim">
|
||||
<type>boolean</type>
|
||||
<value>false</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<type>clock</type>
|
||||
<isStart>false</isStart>
|
||||
<port>
|
||||
<name>clock</name>
|
||||
<direction>Input</direction>
|
||||
<width>1</width>
|
||||
<role>clk</role>
|
||||
</port>
|
||||
</interface>
|
||||
<interface name="reset" kind="reset_sink" version="24.1">
|
||||
<!-- The connection points exposed by a module instance for the
|
||||
particular module parameters. Connection points and their
|
||||
parameters are a RESULT of the module parameters. -->
|
||||
<parameter name="associatedClock">
|
||||
<type>java.lang.String</type>
|
||||
<value>clock</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="synchronousEdges">
|
||||
<type>com.altera.sopcmodel.reset.Reset$Edges</type>
|
||||
<value>DEASSERT</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="deviceFamily">
|
||||
<type>java.lang.String</type>
|
||||
<value>UNKNOWN</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="generateLegacySim">
|
||||
<type>boolean</type>
|
||||
<value>false</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<type>reset</type>
|
||||
<isStart>false</isStart>
|
||||
<port>
|
||||
<name>reset</name>
|
||||
<direction>Input</direction>
|
||||
<width>1</width>
|
||||
<role>reset</role>
|
||||
</port>
|
||||
</interface>
|
||||
</module>
|
||||
<module name="sc_config_0" kind="sc_config" version="1.0" path="sc_config_0">
|
||||
<!-- Describes a single module. Module parameters are
|
||||
the requested settings for a module instance. -->
|
||||
@ -12666,6 +13278,57 @@ parameters are a RESULT of the module parameters. -->
|
||||
<endModule>intel_generic_serial_flash_interface_top_0</endModule>
|
||||
<endConnectionPoint>avl_csr</endConnectionPoint>
|
||||
</connection>
|
||||
<connection
|
||||
name="ibex_0.avalon_master_bus_data/remote_update_0.avl_csr"
|
||||
kind="avalon"
|
||||
version="24.1"
|
||||
start="ibex_0.avalon_master_bus_data"
|
||||
end="remote_update_0.avl_csr">
|
||||
<parameter name="arbitrationPriority">
|
||||
<type>int</type>
|
||||
<value>1</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="baseAddress">
|
||||
<type>java.math.BigInteger</type>
|
||||
<value>0x0002a000</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="defaultConnection">
|
||||
<type>boolean</type>
|
||||
<value>false</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="deviceFamily">
|
||||
<type>java.lang.String</type>
|
||||
<value>UNKNOWN</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="generateLegacySim">
|
||||
<type>boolean</type>
|
||||
<value>false</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<startModule>ibex_0</startModule>
|
||||
<startConnectionPoint>avalon_master_bus_data</startConnectionPoint>
|
||||
<endModule>remote_update_0</endModule>
|
||||
<endConnectionPoint>avl_csr</endConnectionPoint>
|
||||
</connection>
|
||||
<connection
|
||||
name="ibex_0.avalon_master_bus_data/intel_generic_serial_flash_interface_top_0.avl_mem"
|
||||
kind="avalon"
|
||||
@ -13602,6 +14265,33 @@ parameters are a RESULT of the module parameters. -->
|
||||
<endModule>i2c_opencores_1</endModule>
|
||||
<endConnectionPoint>clock</endConnectionPoint>
|
||||
</connection>
|
||||
<connection
|
||||
name="clk_27.clk/remote_update_0.clock"
|
||||
kind="clock"
|
||||
version="24.1"
|
||||
start="clk_27.clk"
|
||||
end="remote_update_0.clock">
|
||||
<parameter name="deviceFamily">
|
||||
<type>java.lang.String</type>
|
||||
<value>UNKNOWN</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="generateLegacySim">
|
||||
<type>boolean</type>
|
||||
<value>false</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<startModule>clk_27</startModule>
|
||||
<startConnectionPoint>clk</startConnectionPoint>
|
||||
<endModule>remote_update_0</endModule>
|
||||
<endConnectionPoint>clock</endConnectionPoint>
|
||||
</connection>
|
||||
<connection
|
||||
name="clk_27.clk/sc_config_0.clock_sink"
|
||||
kind="clock"
|
||||
@ -14012,6 +14702,33 @@ parameters are a RESULT of the module parameters. -->
|
||||
<endModule>intel_generic_serial_flash_interface_top_0</endModule>
|
||||
<endConnectionPoint>reset</endConnectionPoint>
|
||||
</connection>
|
||||
<connection
|
||||
name="clk_27.clk_reset/remote_update_0.reset"
|
||||
kind="reset"
|
||||
version="24.1"
|
||||
start="clk_27.clk_reset"
|
||||
end="remote_update_0.reset">
|
||||
<parameter name="deviceFamily">
|
||||
<type>java.lang.String</type>
|
||||
<value>UNKNOWN</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<parameter name="generateLegacySim">
|
||||
<type>boolean</type>
|
||||
<value>false</value>
|
||||
<derived>false</derived>
|
||||
<enabled>true</enabled>
|
||||
<visible>true</visible>
|
||||
<valid>true</valid>
|
||||
</parameter>
|
||||
<startModule>clk_27</startModule>
|
||||
<startConnectionPoint>clk_reset</startConnectionPoint>
|
||||
<endModule>remote_update_0</endModule>
|
||||
<endConnectionPoint>reset</endConnectionPoint>
|
||||
</connection>
|
||||
<connection
|
||||
name="clk_27.clk_reset/onchip_memory2_0.reset1"
|
||||
kind="reset"
|
||||
@ -14277,7 +14994,7 @@ parameters are a RESULT of the module parameters. -->
|
||||
<version>1.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<instanceCount>15</instanceCount>
|
||||
<instanceCount>16</instanceCount>
|
||||
<name>clock_sink</name>
|
||||
<type>com.altera.entityinterfaces.IElementClass</type>
|
||||
<subtype>com.altera.entityinterfaces.IMutableConnectionPoint</subtype>
|
||||
@ -14285,7 +15002,7 @@ parameters are a RESULT of the module parameters. -->
|
||||
<version>24.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<instanceCount>16</instanceCount>
|
||||
<instanceCount>17</instanceCount>
|
||||
<name>reset_sink</name>
|
||||
<type>com.altera.entityinterfaces.IElementClass</type>
|
||||
<subtype>com.altera.entityinterfaces.IMutableConnectionPoint</subtype>
|
||||
@ -14293,7 +15010,7 @@ parameters are a RESULT of the module parameters. -->
|
||||
<version>24.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<instanceCount>16</instanceCount>
|
||||
<instanceCount>17</instanceCount>
|
||||
<name>avalon_slave</name>
|
||||
<type>com.altera.entityinterfaces.IElementClass</type>
|
||||
<subtype>com.altera.entityinterfaces.IMutableConnectionPoint</subtype>
|
||||
@ -14420,6 +15137,14 @@ parameters are a RESULT of the module parameters. -->
|
||||
<displayName>Reset Bridge</displayName>
|
||||
<version>24.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<instanceCount>1</instanceCount>
|
||||
<name>altera_remote_update</name>
|
||||
<type>com.altera.entityinterfaces.IElementClass</type>
|
||||
<subtype>com.altera.entityinterfaces.IModule</subtype>
|
||||
<displayName>Remote Update Intel FPGA IP</displayName>
|
||||
<version>24.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<instanceCount>1</instanceCount>
|
||||
<name>sc_config</name>
|
||||
@ -14437,7 +15162,7 @@ parameters are a RESULT of the module parameters. -->
|
||||
<version>24.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<instanceCount>21</instanceCount>
|
||||
<instanceCount>22</instanceCount>
|
||||
<name>avalon</name>
|
||||
<type>com.altera.entityinterfaces.IElementClass</type>
|
||||
<subtype>com.altera.entityinterfaces.IConnection</subtype>
|
||||
@ -14445,7 +15170,7 @@ parameters are a RESULT of the module parameters. -->
|
||||
<version>24.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<instanceCount>15</instanceCount>
|
||||
<instanceCount>16</instanceCount>
|
||||
<name>clock</name>
|
||||
<type>com.altera.entityinterfaces.IElementClass</type>
|
||||
<subtype>com.altera.entityinterfaces.IConnection</subtype>
|
||||
@ -14461,7 +15186,7 @@ parameters are a RESULT of the module parameters. -->
|
||||
<version>24.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<instanceCount>15</instanceCount>
|
||||
<instanceCount>16</instanceCount>
|
||||
<name>reset</name>
|
||||
<type>com.altera.entityinterfaces.IElementClass</type>
|
||||
<subtype>com.altera.entityinterfaces.IConnection</subtype>
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
@ -35,6 +36,18 @@
|
||||
|
||||
#define FW_HDR_LEN 26
|
||||
|
||||
typedef struct {
|
||||
char fw_key[4];
|
||||
uint8_t version_major;
|
||||
uint8_t version_minor;
|
||||
char version_suffix[8];
|
||||
uint32_t hdr_len;
|
||||
uint32_t data_len;
|
||||
uint32_t data_crc;
|
||||
char padding[482];
|
||||
uint32_t hdr_crc;
|
||||
} __attribute__((packed)) fw_header;
|
||||
|
||||
static uint32_t crc32_tab[] = {
|
||||
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
|
||||
0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
|
||||
@ -94,99 +107,170 @@ uint32_t crc32(uint32_t crc, const void *buf, size_t size)
|
||||
return crc ^ ~0U;
|
||||
}
|
||||
|
||||
void bitswap8_buf(unsigned char *buf, size_t length)
|
||||
{
|
||||
for (size_t i=0; i<length; i++)
|
||||
buf[i] = ((buf[i] * 0x0802LU & 0x22110LU) | (buf[i] * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
unsigned char block;
|
||||
|
||||
int fd_i, fd_o;
|
||||
struct stat fileinfo;
|
||||
|
||||
int fd_i[2], fd_o;
|
||||
struct stat fileinfo[2];
|
||||
char fw_bin_name[MAX_FILENAME];
|
||||
char hdrbuf[HDR_SIZE];
|
||||
char rdbuf[BUF_SIZE];
|
||||
unsigned fw_version_major;
|
||||
unsigned fw_version_minor;
|
||||
uint32_t hdr_crc;
|
||||
uint32_t crc = 0;
|
||||
|
||||
unsigned int i, bytes_read, bytes_written, tot_bytes_read = 0;
|
||||
|
||||
if ((argc < 3) || (argc > 4)) {
|
||||
printf("Usege: %s rbf version [version_suffix]\n", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((fd_i = open(argv[1], O_RDONLY)) == -1 || fstat(fd_i, &fileinfo) == -1) {
|
||||
printf("Couldn't open input file\n");
|
||||
fw_header hdr = {0};
|
||||
unsigned fw_version_major, fw_version_minor;
|
||||
int legacy_mode = 0;
|
||||
uint32_t bin_offset, padding;
|
||||
|
||||
unsigned int i, bytes_read, bytes_written, tot_bytes_read[3] = {0, 0, 0};
|
||||
|
||||
if ((argc < 3) || (argc > 6)) {
|
||||
printf("Usage: %s rbf bin bin_offset version [version_suffix]\nLegacy usage: %s rbf version [version_suffix]\n", argv[0], argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
snprintf(fw_bin_name, MAX_FILENAME-1, "ossc_%s%s%s.bin", argv[2], (argc == 4) ? "-" : "", (argc == 4) ? argv[3] : "");
|
||||
|
||||
if ((fd_o = open(fw_bin_name, O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR)) == -1) {
|
||||
if (argc < 5)
|
||||
legacy_mode = 1;
|
||||
|
||||
if ((fd_i[0] = open(argv[1], O_RDONLY)) == -1 || fstat(fd_i[0], &fileinfo[0]) == -1) {
|
||||
printf("Couldn't open input RBF file\n");
|
||||
return -1;
|
||||
}
|
||||
if (!legacy_mode) {
|
||||
if ((fd_i[1] = open(argv[2], O_RDONLY)) == -1 || fstat(fd_i[1], &fileinfo[1]) == -1) {
|
||||
printf("Couldn't open input BIN file\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (legacy_mode)
|
||||
snprintf(fw_bin_name, MAX_FILENAME-1, "ossc_%s%s%s.bin", argv[2], (argc == 4) ? "-" : "", (argc == 4) ? argv[3] : "");
|
||||
else
|
||||
snprintf(fw_bin_name, MAX_FILENAME-1, "ossc_%s%s%s.bin", argv[4], (argc == 6) ? "-" : "", (argc == 6) ? argv[5] : "");
|
||||
|
||||
if ((fd_o = open(fw_bin_name, O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) == -1) {
|
||||
printf("Couldn't open output file\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((sscanf(argv[2], "%u.%u", &fw_version_major, &fw_version_minor) != 2) || (fw_version_major > 255) || (fw_version_minor > 255)) {
|
||||
if ((sscanf(legacy_mode ? argv[2] : argv[4], "%u.%u", &fw_version_major, &fw_version_minor) != 2) || (fw_version_major > 255) || (fw_version_minor > 255)) {
|
||||
printf("Invalid version format specified\n");
|
||||
return -1;
|
||||
}
|
||||
//printf("%s, %u.%u\n", argv[2], fw_version_major, (uint8_t)fw_version_minor);
|
||||
|
||||
memset(hdrbuf, 0x00, HDR_SIZE);
|
||||
snprintf(hdrbuf, FW_KEY_SIZE+1, "OSSC");
|
||||
hdrbuf[4] = (uint8_t)fw_version_major;
|
||||
hdrbuf[5] = (uint8_t)fw_version_minor;
|
||||
snprintf(hdrbuf+6, FW_SUFFIX_MAX_SIZE+1, (argc == 4) ? argv[3] : "");
|
||||
*((uint32_t*)(hdrbuf+6+FW_SUFFIX_MAX_SIZE)) = htonl(FW_HDR_LEN);
|
||||
*((uint32_t*)(hdrbuf+6+FW_SUFFIX_MAX_SIZE+4)) = htonl((uint32_t)fileinfo.st_size);
|
||||
snprintf(hdr.fw_key, FW_KEY_SIZE+1, "OSSC");
|
||||
hdr.version_major = (uint8_t)fw_version_major;
|
||||
hdr.version_minor = (uint8_t)fw_version_minor;
|
||||
snprintf(hdr.version_suffix, FW_SUFFIX_MAX_SIZE, legacy_mode ? ((argc == 4) ? argv[3] : "") : ((argc == 6) ? argv[5] : ""));
|
||||
hdr.hdr_len = htobe32(FW_HDR_LEN);
|
||||
|
||||
// data CRC
|
||||
while ((bytes_read = read(fd_i, rdbuf, BUF_SIZE)) > 0) {
|
||||
crc = crc32(crc, rdbuf, bytes_read);
|
||||
tot_bytes_read += bytes_read;
|
||||
if (legacy_mode) {
|
||||
hdr.data_len = htobe32((uint32_t)fileinfo[0].st_size);
|
||||
|
||||
// data CRC (rbf)
|
||||
while ((bytes_read = read(fd_i[0], rdbuf, BUF_SIZE)) > 0) {
|
||||
hdr.data_crc = crc32(hdr.data_crc, rdbuf, bytes_read);
|
||||
tot_bytes_read[0] += bytes_read;
|
||||
}
|
||||
} else {
|
||||
bin_offset = (uint32_t)strtol(argv[3], NULL, 16);
|
||||
|
||||
// data CRC (rbf)
|
||||
while ((bytes_read = read(fd_i[0], rdbuf, BUF_SIZE)) > 0) {
|
||||
hdr.data_crc = crc32(hdr.data_crc, rdbuf, bytes_read);
|
||||
tot_bytes_read[0] += bytes_read;
|
||||
}
|
||||
// data CRC (padding)
|
||||
memset(rdbuf, 0xff, sizeof(rdbuf));
|
||||
padding = bin_offset - tot_bytes_read[0];
|
||||
while (tot_bytes_read[1] < padding) {
|
||||
bytes_read = ((padding-tot_bytes_read[1]) > sizeof(rdbuf)) ? sizeof(rdbuf) : (padding-tot_bytes_read[1]);
|
||||
hdr.data_crc = crc32(hdr.data_crc, rdbuf, bytes_read);
|
||||
tot_bytes_read[1] += bytes_read;
|
||||
}
|
||||
// data CRC (bin)
|
||||
while ((bytes_read = read(fd_i[1], rdbuf, BUF_SIZE)) > 0) {
|
||||
bitswap8_buf(rdbuf, bytes_read);
|
||||
hdr.data_crc = crc32(hdr.data_crc, rdbuf, bytes_read);
|
||||
tot_bytes_read[2] += bytes_read;
|
||||
}
|
||||
hdr.data_len = htobe32((uint32_t)fileinfo[0].st_size+padding+(uint32_t)fileinfo[1].st_size);
|
||||
}
|
||||
*((uint32_t*)(hdrbuf+6+FW_SUFFIX_MAX_SIZE+8)) = htonl(crc);
|
||||
|
||||
// header CRC
|
||||
hdr_crc = crc32(0, hdrbuf, FW_HDR_LEN);
|
||||
*((uint32_t*)(hdrbuf+HDR_SIZE-4)) = htonl(hdr_crc);
|
||||
hdr.data_crc = htobe32(hdr.data_crc);
|
||||
hdr.hdr_crc = crc32(0, &hdr, FW_HDR_LEN);
|
||||
hdr.hdr_crc = htobe32(hdr.hdr_crc);
|
||||
|
||||
if (tot_bytes_read != fileinfo.st_size) {
|
||||
printf("Incorrect size output file\n");
|
||||
return -1;
|
||||
if ((tot_bytes_read[0] != fileinfo[0].st_size) || (!legacy_mode && (tot_bytes_read[2] != fileinfo[1].st_size))) {
|
||||
printf("Incorrect size input data read\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("version %u.%u%s%s: %u bytes\n", fw_version_major, fw_version_minor, (argc == 4) ? "-" : "", hdrbuf+6, fileinfo.st_size);
|
||||
printf("Header CRC32: %.8x\n", hdr_crc);
|
||||
printf("Data CRC32: %.8x\n", crc);
|
||||
printf("version %u.%u%s%s: %u bytes\n", fw_version_major, fw_version_minor, (argc == 4+2*!legacy_mode) ? "-" : "", hdr.version_suffix, tot_bytes_read[0]+tot_bytes_read[1]+tot_bytes_read[2]);
|
||||
printf("Header CRC32: %.8x\n", htobe32(hdr.hdr_crc));
|
||||
printf("Data CRC32: %.8x\n", htobe32(hdr.data_crc));
|
||||
|
||||
bytes_written = write(fd_o, hdrbuf, HDR_SIZE);
|
||||
bytes_written = write(fd_o, &hdr, HDR_SIZE);
|
||||
if (bytes_written != HDR_SIZE) {
|
||||
printf("Couldn't write output file\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
tot_bytes_read = 0;
|
||||
lseek(fd_i, 0, SEEK_SET);
|
||||
while ((bytes_read = read(fd_i, rdbuf, BUF_SIZE)) > 0) {
|
||||
tot_bytes_read[0] = 0;
|
||||
lseek(fd_i[0], 0, SEEK_SET);
|
||||
while ((bytes_read = read(fd_i[0], rdbuf, BUF_SIZE)) > 0) {
|
||||
bytes_written = write(fd_o, rdbuf, bytes_read);
|
||||
if (bytes_written != bytes_read) {
|
||||
printf("Couldn't write output file\n");
|
||||
return -1;
|
||||
}
|
||||
tot_bytes_read += bytes_read;
|
||||
tot_bytes_read[0] += bytes_read;
|
||||
}
|
||||
|
||||
if (tot_bytes_read != fileinfo.st_size) {
|
||||
if (tot_bytes_read[0] != fileinfo[0].st_size) {
|
||||
printf("Incorrect size output file\n");
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!legacy_mode) {
|
||||
memset(rdbuf, 0xff, sizeof(rdbuf));
|
||||
while (tot_bytes_read[1] > 0) {
|
||||
bytes_read = (tot_bytes_read[1] > sizeof(rdbuf)) ? sizeof(rdbuf) : tot_bytes_read[1];
|
||||
bytes_written = write(fd_o, rdbuf, bytes_read);
|
||||
if (bytes_written != bytes_read) {
|
||||
printf("Couldn't write output file\n");
|
||||
return -1;
|
||||
}
|
||||
tot_bytes_read[1] -= bytes_read;
|
||||
}
|
||||
|
||||
tot_bytes_read[2] = 0;
|
||||
lseek(fd_i[1], 0, SEEK_SET);
|
||||
while ((bytes_read = read(fd_i[1], rdbuf, BUF_SIZE)) > 0) {
|
||||
bitswap8_buf(rdbuf, bytes_read);
|
||||
bytes_written = write(fd_o, rdbuf, bytes_read);
|
||||
if (bytes_written != bytes_read) {
|
||||
printf("Couldn't write output file\n");
|
||||
return -1;
|
||||
}
|
||||
tot_bytes_read[2] += bytes_read;
|
||||
}
|
||||
if (tot_bytes_read[2] != fileinfo[1].st_size) {
|
||||
printf("Incorrect size output bin file\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
printf("Firmware image written to %s\n", fw_bin_name);
|
||||
|
||||
|
||||
close(fd_o);
|
||||
close(fd_i);
|
||||
|
||||
close(fd_i[0]);
|
||||
if (!legacy_mode)
|
||||
close(fd_i[1]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user