Заменен абсолютный путь на относительный

This commit is contained in:
sh-sergey committed 2024-11-05 12:02:51 +03:00
1 parent c821a3c5fd
commit 50d0e3a9d5
23 files changed
+64 -26

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
.vscode
idedata.json
@@ -0,0 +1,111 @@
:020000040200F8
:10000000FD62938202400100FD12E39E02FE374131
:10001000000213010100B70100029381016CB705D2
:1000200000029385056C370600021306066CB706BE
:1000300000029386066C39A083A2050023A0560017
:1000400091059106E3EAC5FEB70500029385056CAC
:10005000370600021306066CB70600029386066C8C
:1000600039A083A2050023A0560091059106E3EA7A
:10007000C5FEB70500029385056C3706000213061E
:10008000066C21A023A005009105E3EDC5FEB70095
:100090000002E780C00AB7000002E780C00AB7008C
:1000A0000002E780E02273005010F5BF828000005C
:1000B0000000000000000000000000000000000040
:1000C0006F004000197106C20AC40EC612C816CAD3
:1000D0001ACC1ECE22D026D22AD42ED632D836DA48
:1000E0003ADC3EDEC2C0C6C2CAC4CEC6D2C8D6CA78
:1000F000DACCDECEE2D0E6D2EAD4EED6F2D8F6DA28
:10010000FADCFEDE970000009380E00482909240CB
:100110002241B2414242D2426243F24302549254DB
:100120002255B2554256D2566257F2570648964863
:100130002649B649464AD64A664BF64B065C965C5B
:10014000265DB65D465ED65E665FF65F096173004A
:10015000203001A03D432A876373C3029377F700E1
:10016000BDEFADE5937606FF3D8ABA960CC34CC34E
:100170000CC74CC74107E36BD7FE11E28280B30680
:10018000C3408A069702000096966780A600230760
:10019000B700A306B7002306B700A305B7002305E1
:1001A000B700A304B7002304B700A303B7002303D9
:1001B000B700A302B7002302B700A301B7002301D1
:1001C000B700A300B7002300B700828093F5F50FB6
:1001D00093968500D58D93960501D58D61B793963D
:1001E00027009702000096968682E78086FA96801E
:1001F000C1171D8F3E96E374C3F8A5B75D71130652
:1002000080028145280886C6B137BD47230CF1001E
:100210008947230EF1003ED2E177938707082C0827
:100220000A85231AF102F926B64061618280317194
:1002300006DF22DD26DB4AD94ED752D55AD156D316
:10024000753F6146814528003137B707070093871E
:100250000740B74900023EC2938709808443616723
:100260001307076AA18093F4F4038D461306000276
:100270008145480037290002616A9E0469201309FC
:100280000980014493890980130A0A6A130B000844
:10029000634494008147A9A8931A040193DA0A01E0
:1002A000D2870147930600024A86D68548006D280A
:1002B0001306000881450810713D5287930600021D
:1002C0001010D68548000D2201471C10BA9783C62E
:1002D0000700B307270183C70700638ED700935732
:1002E0007440A207E206D58F4207D98F93E7270013
:1002F00023A0F90001A00507E31967FD1304040812
:100300001309090871B71C418E0603A88700B3E6DC
:10031000060193E6060894C7144999CA814663DD2D
:10032000C600CCC323A007003A850DE50D458280A9
:10033000CCC3814663CCC600944793E6360094C78D
:1003400075D7C8477D17058965FD828023A0070002
:100350008506CDB703A8C7007D1513781800E316EE
:1003600008FC8506910565BF032805000E07832854
:10037000880033671701136707082324E80018492A
:1003800005C301476353D702131527002322B80082
:10039000329508412320A8003E850DED0D45828051
:1003A0002322B8000147634FD70003278800136753
:1003B00057002324E800FDD30325C800FD17058955
:1003C0007DF9828093152700B2958C410507232083
:1003D000B800D1BF8328C8007D1593F81800E39EAC
:1003E00008FA0507910579BF1C4989CF814763FF4A
:1003F000D70003280500BA882322B80063910802B9
:100400000D45828008414CC163E4D70001458280DC
:100410000C411397270032970CC38507F5B70323C8
:10042000C800FD1813731300E31A03FC83280800A7
:10043000139827003298232018018507910545BF9E
:100440000547AA876305E50209476300E5060545F8
:1004500091EBB7060600DC4A7D771307F73FF98F6B
:10046000DCCA014582807D1719EB0D458280930619
:10047000004037A7070013070712B7050500905D76
:100480007D8E75D2370606005C4A7D771307F73FED
:10049000F98FD58F41115CCA02C613073006B247E7
:1004A0006359F70001454101828085669386068085
:1004B000C9B7B24785073EC6DDB791476307F50266
:1004C00063EAA7008547630AF50489476309F504D1
:1004D00005458280A147E31DF5FE0947094501A8AE
:1004E000FD1781EFC8D20D45828005470D45B7A79E
:1004F000070093870712B7060500905E798E6DD2CC
:100500008A05C98D4111CCD202C613073006B24705
:10051000635AF7000145410182801147C9BF214755
:100520000145F1B7B24785073EC6D5B70547AA874B
:100530006305E50209476302E506054591EBB70649
:1005400006009C4A7D771307F73FF98F9CCA014547
:1005500082807D1719EB0D4582809306004037A7F6
:10056000070013070712B7050500905D7D8E75D251
:10057000370706001C4B7D761306F63FF18FD58FAB
:100580001CCB85471CCF411102C613073006B2476A
:100590006359F70001454101828085669386068094
:1005A0007DBFB24785073EC6DDB711C98547630DDC
:1005B000F50205458280FD1791EB0D4582800946C5
:1005C000B7A7070093870712B7060500985E718FDB
:1005D0007DD34111C8D602C613073006B247635710
:1005E000F7000145410182800546D9BFB247850722
:1005F0003EC6EDB7011126CAB7040600DC4806CE98
:1006000022CC4AC84EC652C456C2F19BDCC89C4894
:100610002A89C845F19B9CC883C7C5012E848A07D7
:10062000DCC883C7D5018A079CC8193D0C44AA8A37
:100630000345440059351848B70705002A8A98C36E
:1006400058480850D8C3184C98C7CD35AA89485087
:10065000A93F834704002A8793F6170089E6D44808
:1006600093E62600D4C893F6270099E637060600DD
:10067000544A93E6160054CA93F6470099E63706A3
:100680000600144A93E6260014CAA18B99E7B70620
:1006900006009C4A93E717009CCAF240624423205C
:1006A000590123224901232439012326E900D24498
:1006B000B249224A924A4A85424905618280000035
:0400000502000000F5
:00000001FF
+39
View File
@@ -0,0 +1,39 @@
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.
```src/main.c
#include "header.h"
int main (void)
{
...
}
```
Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.
In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.
Read more about using header files in official GCC documentation:
* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
+46
View File
@@ -0,0 +1,46 @@
This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.
The source code of each library should be placed in a an own separate directory
("lib/your_library_name/[here are source files]").
For example, see a structure of the following two libraries `Foo` and `Bar`:
|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c
and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>
int main (void)
{
...
}
```
PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.
More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html
+15
View File
@@ -0,0 +1,15 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:mik32v2]
platform = MIK32
board = mik32v2
framework = framework-mik32v2-sdk
board_debug.ldscript = ram
+19
View File
@@ -0,0 +1,19 @@
OUTPUT_FORMAT("elf32-littleriscv", "elf32-littleriscv", "elf32-littleriscv")
OUTPUT_ARCH(riscv)
ENTRY(_start)
MEMORY {
ram (RWX): ORIGIN = 0x02000000, LENGTH = 16K
}
STACK_SIZE = 512;
CL_SIZE = 16;
REGION_ALIAS("REGION_TEXT", ram);
REGION_ALIAS("REGION_RAM", ram);
INCLUDE sections.lds
+105
View File
@@ -0,0 +1,105 @@
SECTIONS {
.text ORIGIN(REGION_TEXT) : {
PROVIDE(__TEXT_START__ = .);
*crt0.o(.text .text.*)
*(.text.smallsysteminit)
*(.text.SmallSystemInit)
. = ORIGIN(REGION_TEXT) + 0xC0;
KEEP(*crt0.o(.trap_text))
*(.text)
*(.text.*)
*(.rodata)
*(.rodata.*)
. = ALIGN(CL_SIZE);
PROVIDE(__TEXT_END__ = .);
} >REGION_TEXT
.data :
AT( __TEXT_END__ ) {
PROVIDE(__DATA_START__ = .);
_gp = .;
*(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4) *(.srodata.cst2) *(.srodata*)
*(.sdata .sdata.* .gnu.linkonce.s.*)
*(.data .data.*)
. = ALIGN(CL_SIZE);
PROVIDE(__DATA_END__ = .);
} >REGION_RAM
__DATA_IMAGE_START__ = LOADADDR(.data);
__DATA_IMAGE_END__ = LOADADDR(.data) + SIZEOF(.data);
/* thread-local data segment */
.tdata : {
PROVIDE(_tls_data = .);
PROVIDE(_tdata_begin = .);
*(.tdata .tdata.*)
PROVIDE(_tdata_end = .);
. = ALIGN(CL_SIZE);
} >REGION_RAM
.tbss : {
PROVIDE(__BSS_START__ = .);
*(.tbss .tbss.*)
. = ALIGN(CL_SIZE);
PROVIDE(_tbss_end = .);
} >REGION_RAM
/* bss segment */
.sbss : {
*(.sbss .sbss.* .gnu.linkonce.sb.*)
*(.scommon)
} >REGION_RAM
.bss : {
*(.bss .bss.*)
*(COMMON)
. = ALIGN(CL_SIZE);
PROVIDE(__BSS_END__ = .);
} >REGION_RAM
/* Code intended to be copied to REGION_RAM before execution */
.ram_text :
AT( ALIGN(__DATA_IMAGE_END__, CL_SIZE) ) {
PROVIDE(__RAM_TEXT_START__ = .);
*(.ram_text)
. = ALIGN(CL_SIZE);
PROVIDE(__RAM_TEXT_END__ = .);
} > REGION_RAM
__RAM_TEXT_IMAGE_START__ = LOADADDR(.ram_text);
__RAM_TEXT_IMAGE_END__ = LOADADDR(.ram_text) + SIZEOF(.ram_text);
ASSERT(__RAM_TEXT_IMAGE_END__ < ORIGIN(REGION_TEXT) + LENGTH(REGION_TEXT), "REGION_TEXT segment overflows")
ASSERT(__RAM_TEXT_END__ < ORIGIN(REGION_RAM) + LENGTH(REGION_RAM) - STACK_SIZE, "REGION_RAM section overflows")
_end = .;
PROVIDE(__end = .);
BUFFER_SIZE = 8K;
.buffer ORIGIN(REGION_RAM) + 6K : {
FILL(0);
PROVIDE(__BUFFER__END__ = .);
PROVIDE(BUFFER = .);
. += BUFFER_SIZE;
PROVIDE(BUFFER_STATUS = .);
. += 4;
PROVIDE(__BUFFER__END__ = .);
} >REGION_RAM
/* End of uninitalized data segement */
.stack ORIGIN(REGION_RAM) + LENGTH(REGION_RAM) - STACK_SIZE : {
FILL(0);
PROVIDE(__STACK_START__ = .);
. += STACK_SIZE;
PROVIDE(__C_STACK_TOP__ = .);
PROVIDE(__STACK_END__ = .);
} >REGION_RAM
/DISCARD/ : {
*(.eh_frame .eh_frame.*)
}
}
+136
View File
@@ -0,0 +1,136 @@
#include "mik32_hal_pcc.h"
#include "mik32_hal_eeprom.h"
#include "uart_lib.h"
#include "xprintf.h"
/*
31 8 7 0
|--------------|----|
code data code
*/
#define STATUS_CODE_S 0
#define STATUS_CODE(X) ((X) << STATUS_CODE_S)
#define STATUS_CODE_OK 0
#define STATUS_CODE_START 1
#define STATUS_CODE_MISMATCH 2
#define STATUS_CODE_START_PAGE_COUNT_S 8
#define STATUS_CODE_START_PAGE_COUNT_M ((64 - 1) << STATUS_CODE_START_PAGE_COUNT_S)
#define STATUS_CODE_MISMATCH_PAGE_S 8
#define STATUS_CODE_MISMATCH_BYTE_S 16
#define STATUS_CODE_MISMATCH_VALUE_S 24
#define STATUS_CODE_MISMATCH_PAGE(X) ((X) << STATUS_CODE_MISMATCH_PAGE_S)
#define STATUS_CODE_MISMATCH_BYTE(X) ((X) << STATUS_CODE_MISMATCH_BYTE_S)
#define STATUS_CODE_MISMATCH_VALUE(X) ((X) << STATUS_CODE_MISMATCH_VALUE_S)
const int BUFFER_SIZE = 8 * 1024;
extern uint8_t *BUFFER[];
extern uint32_t BUFFER_STATUS[];
#define EEPROM_OP_TIMEOUT 100000
#define USART_TIMEOUT 1000
#define EEPROM_PAGE_WORDS 32
#define EEPROM_PAGE_COUNT 64
void SystemClock_Config(void);
void EEPROM_Init(void);
HAL_EEPROM_HandleTypeDef heeprom;
int main()
{
SystemClock_Config();
#ifdef UART_DEBUG
UART_Init(UART_0, 278, UART_CONTROL1_TE_M | UART_CONTROL1_M_8BIT_M, 0, 0);
xprintf("START DRIVER\n");
#endif
HAL_EEPROM_HandleTypeDef heeprom = {
.Instance = EEPROM_REGS,
};
int result = STATUS_CODE(STATUS_CODE_OK);
int max_address = ((*BUFFER_STATUS & STATUS_CODE_START_PAGE_COUNT_M) >>
STATUS_CODE_START_PAGE_COUNT_S) *
EEPROM_PAGE_WORDS * 4;
HAL_EEPROM_Erase(&heeprom, 0, EEPROM_PAGE_WORDS, HAL_EEPROM_WRITE_ALL, EEPROM_OP_TIMEOUT);
for (int addr = 0; addr < max_address; addr += (EEPROM_PAGE_WORDS * 4))
{
#ifdef UART_DEBUG
xprintf("Write Page 0x%04x from 0x%08x\n", addr, (uint8_t *)((uint32_t)BUFFER + addr));
#endif
HAL_EEPROM_Write(
&heeprom,
addr,
(uint32_t *)((uint32_t)BUFFER + addr),
EEPROM_PAGE_WORDS,
HAL_EEPROM_WRITE_SINGLE,
EEPROM_OP_TIMEOUT);
uint8_t rb[EEPROM_PAGE_WORDS * 4] = {0};
HAL_EEPROM_Read(&heeprom, addr, (uint32_t *)rb, EEPROM_PAGE_WORDS, EEPROM_OP_TIMEOUT);
for (uint32_t b = 0; b < (EEPROM_PAGE_WORDS * 4); b++)
{
uint8_t ebuf = *(uint8_t *)((uint32_t)BUFFER + addr + b);
if (ebuf != rb[b])
{
#ifdef UART_DEBUG
xprintf("addr[0x%04x:0x%08x] buf:mem = 0x%02x != 0x%02x\n", (uint32_t)BUFFER + addr + b, 0x01000000 + addr + b, ebuf, rb[b]);
#endif
result = STATUS_CODE(STATUS_CODE_MISMATCH) |
STATUS_CODE_MISMATCH_PAGE(addr >> 7) |
STATUS_CODE_MISMATCH_BYTE(b) |
STATUS_CODE_MISMATCH_VALUE(rb[b]);
goto debugger_return;
}
}
}
debugger_return:
*BUFFER_STATUS = result;
// asm ("wfi");
while (1)
;
}
void SystemClock_Config(void)
{
PCC_InitTypeDef PCC_OscInit = {0};
PCC_OscInit.OscillatorEnable = PCC_OSCILLATORTYPE_ALL;
PCC_OscInit.FreqMon.OscillatorSystem = PCC_OSCILLATORTYPE_OSC32M;
PCC_OscInit.FreqMon.ForceOscSys = PCC_FORCE_OSC_SYS_UNFIXED;
PCC_OscInit.FreqMon.Force32KClk = PCC_FREQ_MONITOR_SOURCE_OSC32K;
PCC_OscInit.AHBDivider = 0;
PCC_OscInit.APBMDivider = 0;
PCC_OscInit.APBPDivider = 0;
PCC_OscInit.HSI32MCalibrationValue = 128;
PCC_OscInit.LSI32KCalibrationValue = 128;
PCC_OscInit.RTCClockSelection = PCC_RTC_CLOCK_SOURCE_AUTO;
PCC_OscInit.RTCClockCPUSelection = PCC_CPU_RTC_CLOCK_SOURCE_OSC32K;
HAL_PCC_Config(&PCC_OscInit);
}
void EEPROM_Init()
{
heeprom.Instance = EEPROM_REGS;
heeprom.Mode = HAL_EEPROM_MODE_TWO_STAGE;
heeprom.ErrorCorrection = HAL_EEPROM_ECC_ENABLE;
heeprom.EnableInterrupt = HAL_EEPROM_SERR_DISABLE;
HAL_EEPROM_Init(&heeprom);
HAL_EEPROM_CalculateTimings(&heeprom, OSC_SYSTEM_VALUE);
}
+11
View File
@@ -0,0 +1,11 @@
This directory is intended for PlatformIO Test Runner and project tests.
Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.
More information about PlatformIO Unit Testing:
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html
+1
View File
@@ -0,0 +1 @@
.vscode
@@ -0,0 +1,231 @@
:020000040200F8
:10000000FD62938202400100FD12E39E02FE374131
:10001000000213010100B7110002938101DBB71543
:100020000002938505DB37160002130606DBB716C0
:100030000002938606DB39A083A2050023A05600A8
:1000400091059106E3EAC5FEB7150002938505DB2D
:1000500037160002130606E4B7160002938606DB85
:1000600039A083A2050023A0560091059106E3EA7A
:10007000C5FEB7150002938505DB3716000213068F
:1000800006DB21A023A005009105E3EDC5FEB70026
:100090000002E780C00AB7000002E780C00AB7008C
:1000A0000002E780002373005010F5BF828000003B
:1000B0000000000000000000000000000000000040
:1000C0006F004000197106C20AC40EC612C816CAD3
:1000D0001ACC1ECE22D026D22AD42ED632D836DA48
:1000E0003ADC3EDEC2C0C6C2CAC4CEC6D2C8D6CA78
:1000F000DACCDECEE2D0E6D2EAD4EED6F2D8F6DA28
:10010000FADCFEDE970000009380E00482909240CB
:100110002241B2414242D2426243F24302549254DB
:100120002255B2554256D2566257F2570648964863
:100130002649B649464AD64A664BF64B065C965C5B
:10014000265DB65D465ED65E665FF65F096173004A
:10015000203001A03D432A876373C3029377F700E1
:10016000BDEFADE5937606FF3D8ABA960CC34CC34E
:100170000CC74CC74107E36BD7FE11E28280B30680
:10018000C3408A069702000096966780A600230760
:10019000B700A306B7002306B700A305B7002305E1
:1001A000B700A304B7002304B700A303B7002303D9
:1001B000B700A302B7002302B700A301B7002301D1
:1001C000B700A300B7002300B700828093F5F50FB6
:1001D00093968500D58D93960501D58D61B793963D
:1001E00027009702000096968682E78086FA96801E
:1001F000C1171D8F3E96E374C3F8A5B75D71130652
:1002000080028145280886C6B137BD47230CF1001E
:100210008947230EF1003ED2E177938707082C0827
:100220000A85231AF102EF00607CB640616182808A
:100230000D71232E1114232A9114232251152320EA
:100240006115232E7113232C8113232C8114232851
:1002500021152326311523244115232A9113232800
:10026000A113693F371508000147814621469305D0
:10027000F011130505408D2237150002130505D135
:1002800049291306400281456800E935B707070090
:1002900028003EC4EF00F00337150002130505D215
:1002A0008D292800EF00F01037150002130545D303
:1002B0008D21B72A00023715000293850A00130525
:1002C000C5D48129B7340002054523A00400371B9B
:1002D0000002B92993840400371C0002856BFE8557
:1002E00013050BD67E8A35212800EF00900CA2461C
:1002F000E1679387176AFD1781C7D84E418B65FF69
:10030000D2852800EF00F01493890A000149814C3E
:1003100033044901CE86A285130600102800EF00A1
:10032000900E13060010814508182D35A28514186B
:10033000130600102800EF0010160144130D0010E2
:100340001C18B3858900A29783C6050003C7070060
:100350006387E600228613058CD7652E8D4C050435
:10036000E310A4FF1309091093890910E31279FB24
:10037000054523A094016D2E9DB70111B717080004
:1003800006CE02C402C6938707406312F502B70780
:1003900005000947D8CF930700063EC085473EC2F7
:1003A0008A85374508007126F24005618280B727AB
:1003B000080093870780E319F5FEB707050011478A
:1003C000D8CF930700303EC03745080085473EC26E
:1003D0008A8513050540C1BF011122CC26CA4AC82F
:1003E0004EC652C42A8406CE2E89B284368ABA8971
:1003F0006937BD47014563FE2703232004002326F8
:100400002401FD575CCC2322440193E714002324EC
:10041000340113F744001CC0A1885C4C054501C79A
:1004200013D56701058991CC6DD99396A700E3D6C2
:1004300006FEF2406244D2444249B249224A056172
:10044000828061DDFDB7484D1981058982804111A7
:1004500022C406C62A842285FD3775DDB2402244B7
:10046000410182809317050137150800C1831305E8
:1004700005401CD5E9BF411122C406C62A840305E4
:10048000040009E5B2402244410182800504D93FBD
:10049000FDB75971D6CADAC8DEC6E2C4E6C2EAC000
:1004A00086D6A2D4A6D2CAD0CECED2CC6EDEAA87B1
:1004B0002E8D930A0003130BA002930BC004130CA0
:1004C0000002A94C038507006306052213075002AA
:1004D000138917006311E508038517006310550998
:1004E000038527001389370085446316650B0324B1
:1004F0000D0093074D006355040033048040894488
:10050000030509003E8D05099377F5FD6397770193
:100510000305090093E444000509630D051C130756
:100520000006AA876356A700930705FEE207E18746
:100530001307F0046387E70C6342F70613073004E0
:10054000638BE70A130740046380E70E1307200458
:1005500089466389E70A3937EA8949A01307D00237
:100560006306E50013892700814441B7038527000E
:1005700013893700894495BF3304940305092A94ED
:100580000305F9FF130404FD930705FD93F7F70F27
:10059000E374F7FE95BF01442547FDB713075005E7
:1005A0006384E708130780056382E70813073005B3
:1005B000E393E7FA832D0D0093094D0013FA24000D
:1005C0006E85ED252A8D93041D0063150A00636A6C
:1005D0008D00268D6E854535636A8D004E8DCA87E8
:1005E000D5B513050002BD3D268DF1BF13050002F0
:1005F000953D050DD5B703050D0093094D009D35BB
:10060000F1BFA14613F7440093094D0015C313062B
:10061000400403270D006396C702635407023307A3
:10062000E04093E4040131A8A946E9BFC146D9BF1F
:10063000130740046395E70003270D00F9BF032764
:100640000D00130585F89D4719E193077002100806
:1006500093F5F70F328D8147A5483378D7023A8357
:10066000338505013357D70263E508011315880167
:100670006185130505032300A600938D17006366AB
:10068000D3000506639F8D05FD4713F7040101CFD5
:1006900013870D021408B30DD7001307D00223806F
:1006A000EDFE938D270093F714001305000299C304
:1006B000130500036E8A898813071A0081E46364B6
:1006C0008A023A8AFD1D3307BD0103050700593B25
:1006D000E39A0DFEE3748AF0130500026133050A04
:1006E000D5BFEE879DBF3AC62AC4AD3B32472245EF
:1006F0003A8AD9B7B650265496540659F649664AEE
:10070000D64A464BB64B264C964C064DF25D65617B
:10071000828039712ED24C1006CE32D436D63AD8D9
:100720003EDA42DC46DE2EC6AD33F24021618280E5
:1007300041A5B7470800938707402A886303F50857
:10074000B7570800938707806303F50A3747080007
:10075000630CE50A05458280331E1F013376DE01F6
:1007600039C2C04188431393180033966200134680
:10077000F6FF93743400718DB3946400458D88C383
:10078000630B740205CC084303AEC500718D331EA4
:100790006E003365C50108C38842698E88453315EC
:1007A0006500498E90C2850833D51E0155F5324447
:1007B000A244410182802326C801F1B72324C80145
:1007C000D9B7B716050037170500B7170500938688
:1007D00046C1130707C19387C7C083AE0500814890
:1007E000054F8D42914333D51E0105ED8280B7162A
:1007F000050037170500B7170500938606C21307D3
:10080000C7C1938787C1D1BFB71605003717050049
:10081000B7170500938686C0130747C0938707C0A4
:100820006DBF331E1F013376DE0119E2850865BFF7
:10083000411122C626C435B70547AA876305E502DC
:1008400009476300E506054591EBB7060600DC4A5B
:100850007D771307F73FF98FDCCA014582807D174A
:1008600019EB0D4582809306004037A70700130758
:100870000712B7050500905D7D8E75D2370606001C
:100880005C4A7D771307F73FF98FD58F41115CCA1A
:1008900002C613073006B2476359F700014541010C
:1008A0008280856693860680C9B7B24785073EC6B3
:1008B000DDB791476307F50263EAA7008547630A3E
:1008C000F50489476309F50405458280A147E31DC6
:1008D000F5FE0947094501A8FD1781EFC8D20D456E
:1008E000828005470D45B7A7070093870712B70613
:1008F0000500905E798E6DD28A05C98D4111CCD2EA
:1009000002C613073006B247635AF700014541019A
:1009100082801147C9BF21470145F1B7B24785071A
:100920003EC6D5B70547AA876305E50209476302B6
:10093000E506054591EBB70606009C4A7D7713074F
:10094000F73FF98F9CCA014582807D1719EB0D4551
:1009500082809306004037A7070013070712B705E8
:100960000500905D7D8E75D2370706001C4B7D76A5
:100970001306F63FF18FD58F1CCB85471CCF411155
:1009800002C613073006B2476359F700014541011B
:1009900082808566938606807DBFB24785073EC606
:1009A000DDB711C98547630DF50205458280FD1746
:1009B00091EB0D4582800946B7A707009387071280
:1009C000B7060500985E718F7DD34111C8D602C667
:1009D00013073006B2476357F70001454101828093
:1009E0000546D9BFB24785073EC6EDB7011126CAF5
:1009F000B7040600DC4806CE22CC4AC84EC652C414
:100A000056C2F19BDCC89C482A89C845F19B9CC80A
:100A100083C7C5012E848A07DCC883C7D5018A072E
:100A20009CC8193D0C44AA8A03454400593518480E
:100A3000B70705002A8A98C358480850D8C3184CED
:100A400098C7CD35AA894850A93F834704002A8713
:100A500093F6170089E6D44893E62600D4C893F6A7
:100A6000270099E637060600544A93E6160054CA52
:100A700093F6470099E637060600144A93E62600E7
:100A800014CAA18B99E7B70606009C4A93E71700A2
:100A90009CCAF240624423205901232249012324A5
:100AA00039012326E900D244B249224A924A4A85B2
:100AB000424905618280B7070500DC53054721657F
:100AC0008D8BF9176376F7003755E801130505801C
:100AD0008280011106CE22CC02C402C62147B7078C
:100AE000050037550800D8C705448D478A8513058A
:100AF00005803EC022C23539375508009307C00330
:100B00008A851305058022C222C43EC01D31F240F1
:100B1000624405618280032305002A8E0325C301F8
:100B200013650502232EA3002324C3001396260178
:100B300049824D8E232603012322C300139605010B
:100B40006354060299C20545B1CB01476346D700FD
:100B5000639C08020D4582803386E7000346060049
:100B60000507230AC300DDB799C2054505CB8147B8
:100B7000E3D0D7FE03260E00034546013306F700F7
:100B800085072300A600EDB783270E00FD18DC4F74
:100B900093F70702D5DF11656D8D11E18280B707EC
:100BA000070083C7470113F585001D8D3335A0006D
:100BB00082801C414147D8CF8280E1689388086ACF
:100BC00001488147014781460146B7052006A1B784
:100BD000011106CEA307010089476393F502B7050B
:100BE0002035E1681307F1009388086A01488147BE
:100BF000854601460D37F2400345F10005618280CC
:100C0000B7052005F9BF011106CE22CC26CA2E84D5
:100C10004AC8AA84328936C64D37B247E16822866F
:100C20009388086A01480147CA86B78580022685ED
:100C30006164D5351304146A7D1411C48545268575
:100C4000413F058975F9F2406244D2444249056149
:100C50008280011106CE22CC26CA2EC6AA84B13FBC
:100C60003246E1689388086A014881470147814616
:100C7000B705802026856164793D1304146A7D14CC
:100C800011C485452685A937058975F9F240624466
:100C9000D24405618280E16836879388086AB2860B
:100CA00001482E868147B7058003B5B59377350097
:100CB0002A879DEFB7867F7F9386F6F7FD55104311
:100CC0001107B377D600B697D18FD58FE389B7FEDA
:100CD0008346C7FFB307A7408DCA8346D7FF9DC28F
:100CE0000345E7FF3335A0003E9579158280F9D2A0
:100CF00083470700050793763700F5FB098F130537
:100D0000F7FF82801385D7FF82801385C7FF82801B
:100D10005354415254204452495645520A0000004F
:100D20006D737020696E697420636F6D706C65748B
:100D3000650A0000737069666920726573657420C6
:100D4000636F6D706C6574650A000000425546461D
:100D50004552344B203D203078253038780A000049
:100D6000455241534520534543544F522030782536
:100D70003038780A00000000616464725B307825C6
:100D80003038783A3078253032785D206275663AAE
:100D90006D656D203D2030782530327820213D2052
:100DA0003078253032780A00000000000000000092
:100DB000411122C406C62A84FD39B70705009C43A9
:100DC0001307803E8507B357F502B3D7E7020D67D7
:100DD0001307779CB387E7022167130707D0B3D7C0
:100DE000E70219C4BE82FD12E39F02FE7D147DF866
:100DF000B240224441018280411122C406C62A84A5
:100E00005D39B70705009C431307803E8507B3573C
:100E1000F502B3D7E7022947B387E7022167130733
:100E200007D0B3D7E70219C4BE82FD12E39F02FECA
:100E30007D147DF8B2402244410182800000000010
:0400000502000000F5
:00000001FF
@@ -0,0 +1 @@
{"build_type": "release", "env_name": "mik32v2", "libsource_dirs": ["c:\\Users\\user\\.platformio\\packages\\tool-mik32-uploader\\upload_drivers\\jtag_spifi\\lib", "c:\\Users\\user\\.platformio\\packages\\tool-mik32-uploader\\upload_drivers\\jtag_spifi\\.pio\\libdeps\\mik32v2", "C:\\Users\\user\\.platformio\\lib"], "defines": ["OSC_SYSTEM_VALUE=32000000L", "PLATFORMIO=60115", "MIK32V2"], "includes": {"build": ["c:\\Users\\user\\.platformio\\packages\\tool-mik32-uploader\\upload_drivers\\jtag_spifi\\include", "c:\\Users\\user\\.platformio\\packages\\tool-mik32-uploader\\upload_drivers\\jtag_spifi\\src", "c:\\Users\\user\\.platformio\\packages\\tool-mik32-uploader\\upload_drivers\\jtag_spifi\\-v", "c:\\Users\\user\\.platformio\\packages\\tool-mik32-uploader\\upload_drivers\\jtag_spifi\\src", "C:\\Users\\user\\.platformio\\packages\\framework-mik32v2-sdk\\shared\\include", "C:\\Users\\user\\.platformio\\packages\\framework-mik32v2-sdk\\shared\\periphery", "C:\\Users\\user\\.platformio\\packages\\framework-mik32v2-sdk\\shared\\runtime", "C:\\Users\\user\\.platformio\\packages\\framework-mik32v2-sdk\\shared\\libs", "C:\\Users\\user\\.platformio\\packages\\framework-mik32v2-sdk\\hal\\core\\Include", "C:\\Users\\user\\.platformio\\packages\\framework-mik32v2-sdk\\hal\\peripherals\\Include", "C:\\Users\\user\\.platformio\\packages\\framework-mik32v2-sdk\\hal\\utilities\\Include"], "compatlib": [], "toolchain": ["C:\\Users\\user\\.platformio\\packages\\toolchain-riscv\\riscv-none-elf\\include\\c++\\13.2.0", "C:\\Users\\user\\.platformio\\packages\\toolchain-riscv\\riscv-none-elf\\include\\c++\\13.2.0\\riscv-none-elf", "C:\\Users\\user\\.platformio\\packages\\toolchain-riscv\\lib\\gcc\\riscv-none-elf\\13.2.0\\include", "C:\\Users\\user\\.platformio\\packages\\toolchain-riscv\\lib\\gcc\\riscv-none-elf\\13.2.0\\include-fixed", "C:\\Users\\user\\.platformio\\packages\\toolchain-riscv\\riscv-none-elf\\include"]}, "cc_flags": ["-std=gnu11", "-march=rv32imc_zicsr_zifencei", "-mabi=ilp32", "-mcmodel=medlow", "-Os", "-g3", "-Wall", "-fsigned-char", "-ffunction-sections", "-ffixed-x31"], "cxx_flags": ["-std=gnu++17", "-fabi-version=0", "-fno-exceptions", "-fno-rtti", "-fno-use-cxa-atexit", "-fno-threadsafe-statics", "-march=rv32imc_zicsr_zifencei", "-mabi=ilp32", "-mcmodel=medlow", "-Os", "-g3", "-Wall", "-fsigned-char", "-ffunction-sections", "-ffixed-x31"], "cc_path": "C:\\Users\\user\\.platformio\\packages\\toolchain-riscv\\bin\\riscv-none-elf-gcc.exe", "cxx_path": "C:\\Users\\user\\.platformio\\packages\\toolchain-riscv\\bin\\riscv-none-elf-g++.exe", "gdb_path": "C:\\Users\\user\\.platformio\\packages\\toolchain-riscv\\bin\\riscv-none-elf-gdb.exe", "prog_path": "c:\\Users\\user\\.platformio\\packages\\tool-mik32-uploader\\upload_drivers\\jtag_spifi\\.pio\\build\\mik32v2\\firmware.elf", "svd_path": "C:\\Users\\user\\.platformio\\platforms\\mik32\\misc\\svd\\mik32v2.svd", "compiler_type": "gcc", "targets": [{"name": "upload", "group": "Platform", "title": "Upload"}], "extra": {"flash_images": []}}
+39
View File
@@ -0,0 +1,39 @@
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.
```src/main.c
#include "header.h"
int main (void)
{
...
}
```
Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.
In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.
Read more about using header files in official GCC documentation:
* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
+46
View File
@@ -0,0 +1,46 @@
This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.
The source code of each library should be placed in a an own separate directory
("lib/your_library_name/[here are source files]").
For example, see a structure of the following two libraries `Foo` and `Bar`:
|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c
and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>
int main (void)
{
...
}
```
PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.
More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html
+16
View File
@@ -0,0 +1,16 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:mik32v2]
platform = MIK32
board = mik32v2
framework = framework-mik32v2-sdk
board_debug.ldscript = ram
build_flags = -ffixed-x31 -D MIK32V2
+19
View File
@@ -0,0 +1,19 @@
OUTPUT_FORMAT("elf32-littleriscv", "elf32-littleriscv", "elf32-littleriscv")
OUTPUT_ARCH(riscv)
ENTRY(_start)
MEMORY {
ram (RWX): ORIGIN = 0x02000000, LENGTH = 16K
}
STACK_SIZE = 1024;
CL_SIZE = 16;
REGION_ALIAS("REGION_TEXT", ram);
REGION_ALIAS("REGION_RAM", ram);
INCLUDE sections.lds
+105
View File
@@ -0,0 +1,105 @@
SECTIONS {
.text ORIGIN(REGION_TEXT) : {
PROVIDE(__TEXT_START__ = .);
*crt0.o(.text .text.*)
*(.text.smallsysteminit)
*(.text.SmallSystemInit)
. = ORIGIN(REGION_TEXT) + 0xC0;
KEEP(*crt0.o(.trap_text))
*(.text)
*(.text.*)
*(.rodata)
*(.rodata.*)
. = ALIGN(CL_SIZE);
PROVIDE(__TEXT_END__ = .);
} >REGION_TEXT
.data :
AT( __TEXT_END__ ) {
PROVIDE(__DATA_START__ = .);
_gp = .;
*(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4) *(.srodata.cst2) *(.srodata*)
*(.sdata .sdata.* .gnu.linkonce.s.*)
*(.data .data.*)
. = ALIGN(CL_SIZE);
PROVIDE(__DATA_END__ = .);
} >REGION_RAM
__DATA_IMAGE_START__ = LOADADDR(.data);
__DATA_IMAGE_END__ = LOADADDR(.data) + SIZEOF(.data);
/* thread-local data segment */
.tdata : {
PROVIDE(_tls_data = .);
PROVIDE(_tdata_begin = .);
*(.tdata .tdata.*)
PROVIDE(_tdata_end = .);
. = ALIGN(CL_SIZE);
} >REGION_RAM
.tbss : {
PROVIDE(__BSS_START__ = .);
*(.tbss .tbss.*)
. = ALIGN(CL_SIZE);
PROVIDE(_tbss_end = .);
} >REGION_RAM
/* bss segment */
.sbss : {
*(.sbss .sbss.* .gnu.linkonce.sb.*)
*(.scommon)
} >REGION_RAM
.bss : {
*(.bss .bss.*)
*(COMMON)
. = ALIGN(CL_SIZE);
PROVIDE(__BSS_END__ = .);
} >REGION_RAM
/* Code intended to be copied to REGION_RAM before execution */
.ram_text :
AT( ALIGN(__DATA_IMAGE_END__, CL_SIZE) ) {
PROVIDE(__RAM_TEXT_START__ = .);
*(.ram_text)
. = ALIGN(CL_SIZE);
PROVIDE(__RAM_TEXT_END__ = .);
} > REGION_RAM
__RAM_TEXT_IMAGE_START__ = LOADADDR(.ram_text);
__RAM_TEXT_IMAGE_END__ = LOADADDR(.ram_text) + SIZEOF(.ram_text);
ASSERT(__RAM_TEXT_IMAGE_END__ < ORIGIN(REGION_TEXT) + LENGTH(REGION_TEXT), "REGION_TEXT segment overflows")
ASSERT(__RAM_TEXT_END__ < ORIGIN(REGION_RAM) + LENGTH(REGION_RAM) - STACK_SIZE, "REGION_RAM section overflows")
_end = .;
PROVIDE(__end = .);
BUFFER4K_SIZE = 4K;
.buffer4k ORIGIN(REGION_RAM) + 8K : {
FILL(0);
PROVIDE(__BUFFER4K__END__ = .);
PROVIDE(BUFFER4K = .);
. += BUFFER4K_SIZE;
PROVIDE(BUFFER_STATUS = .);
. += 4;
PROVIDE(__BUFFER4K__END__ = .);
} >REGION_RAM
/* End of uninitalized data segement */
.stack ORIGIN(REGION_RAM) + LENGTH(REGION_RAM) - STACK_SIZE : {
FILL(0);
PROVIDE(__STACK_START__ = .);
. += STACK_SIZE;
PROVIDE(__C_STACK_TOP__ = .);
PROVIDE(__STACK_END__ = .);
} >REGION_RAM
/DISCARD/ : {
*(.eh_frame .eh_frame.*)
}
}
+109
View File
@@ -0,0 +1,109 @@
#include "mik32_hal_pcc.h"
#include "mik32_hal_spifi.h"
#include "mik32_hal_spifi_w25.h"
#include "uart_lib.h"
#include "xprintf.h"
/**
* @file main.c
*
* @brief Пример демонстрирует чтение и запись значений во внешнюю флеш память Winbond W25 по Standard (Single) SPI
*/
// extern char __HEAP_START[];
const int BUFFER4K_SIZE = 4 * 1024;
extern uint8_t *BUFFER4K[];
extern uint32_t *BUFFER_STATUS[];
register uint32_t address_reg asm("x31");
void SystemClock_Config(void);
void read_flash(SPIFI_HandleTypeDef *spifi, uint32_t address, uint8_t dataLength, uint8_t *dataBytes);
int main()
{
// *BUFFER_STATUS = 1;
SystemClock_Config();
UART_Init(UART_0, 287, UART_CONTROL1_TE_M | UART_CONTROL1_M_8BIT_M, 0, 0);
xprintf("START DRIVER\n");
SPIFI_HandleTypeDef spifi = {
.Instance = SPIFI_CONFIG,
};
HAL_SPIFI_MspInit(&spifi);
xprintf("msp init complete\n");
HAL_SPIFI_Reset(&spifi);
xprintf("spifi reset complete\n");
// xprintf("BUFFER4K = 0x%08x\n", BUFFER4K);
*BUFFER_STATUS = 1;
HAL_DelayMs(1);
while (1)
{
uint32_t address = address_reg;
xprintf("ERASE SECTOR 0x%08x\n", address);
// xprintf("*BUFFER_STATUS 0x%08x\n", *BUFFER_STATUS);
// asm ("wfi");
// *BUFFER_STATUS = 1;
// HAL_SPIFI_Reset(&spifi);
// HAL_SPIFI_WaitResetClear(&spifi, HAL_SPIFI_TIMEOUT);
HAL_SPIFI_W25_SectorErase4K(&spifi, address);
int result = 0;
for (int ad = 0; ad < BUFFER4K_SIZE; ad += 256)
{
// xprintf("Write Page 0x%08x from 0x%08x\n", ad + address, (uint8_t *)((uint32_t)BUFFER4K + ad));
HAL_SPIFI_W25_PageProgram(&spifi, address + ad, 256, (uint8_t *)((uint32_t)BUFFER4K + ad));
uint8_t rb[256] = { 0 };
HAL_SPIFI_W25_ReadData(&spifi, address + ad, 256, rb);
for (uint32_t b = 0; b < 256; b++)
{
if (*(uint8_t *)((uint32_t)BUFFER4K + ad + b) != rb[b])
{
xprintf("addr[0x%08x:0x%02x] buf:mem = 0x%02x != 0x%02x\n", (uint32_t)BUFFER4K + ad + b, b, *(uint8_t *)((uint32_t)BUFFER4K + ad + b), rb[b]);
result = 2;
// break;
}
}
}
*BUFFER_STATUS = result;
HAL_DelayMs(1);
// asm ("wfi");
}
while (1)
;
}
void SystemClock_Config(void)
{
PCC_InitTypeDef PCC_OscInit = {0};
PCC_OscInit.OscillatorEnable = PCC_OSCILLATORTYPE_ALL;
PCC_OscInit.FreqMon.OscillatorSystem = PCC_OSCILLATORTYPE_OSC32M;
PCC_OscInit.FreqMon.ForceOscSys = PCC_FORCE_OSC_SYS_UNFIXED;
PCC_OscInit.FreqMon.Force32KClk = PCC_FREQ_MONITOR_SOURCE_OSC32K;
PCC_OscInit.AHBDivider = 0;
PCC_OscInit.APBMDivider = 0;
PCC_OscInit.APBPDivider = 0;
PCC_OscInit.HSI32MCalibrationValue = 128;
PCC_OscInit.LSI32KCalibrationValue = 128;
PCC_OscInit.RTCClockSelection = PCC_RTC_CLOCK_SOURCE_AUTO;
PCC_OscInit.RTCClockCPUSelection = PCC_CPU_RTC_CLOCK_SOURCE_OSC32K;
HAL_PCC_Config(&PCC_OscInit);
}
+11
View File
@@ -0,0 +1,11 @@
This directory is intended for PlatformIO Test Runner and project tests.
Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.
More information about PlatformIO Unit Testing:
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html