Biblioteca Littlefs_portenta_H7
Índice
- Notas importantes para portenta_h7
- Por que precisamos desta biblioteca Littlefs_portenta_H7
- Características
- Placas atualmente suportadas
- Changelog
- Pré -requisitos
- Instalação
- Use o gerente da biblioteca Arduino
- Instalação manual
- Vs código e plataforma
- Patches dos pacotes
- 1. Para placas portenta_h7 usando Arduino IDE em Linux
- Exemplos
- 1. Littlefs_Counting
- 2. Littlefs_test
- Exemplo Littlefs_test
- Amostras de saída do terminal de depuração
- 1. Littlefs_Counting em Portenta_H7_M7
- 2. Littlefs_test em Portenta_H7_M7
- Depurar
- Solução de problemas
- Problemas
- PENDÊNCIA
- FEITO
- Contribuições e obrigado
- Contribuindo
- Licença
- Direitos autorais
Notas importantes para portenta_h7
Os pequenos pequenos da nova placa Portenta_H7 atualmente testaram OK com apenas 8 arquivos . Os arquivos, de 9 anos ou mais, de alguma forma estranhamente não podem ser escritos e / ou lidos. Este é possivelmente um bug no ArduinoCore-mbed mbed_portenta core . O mesmo comportamento é observado do núcleo v2.0.0 até v2.6.1 .
Se o tamanho do Littlefs for reduzido para 1024KB , o teste é bom com apenas 4 arquivos .
Cuidado e continue verificando atualizações.
Por que precisamos desta biblioteca Littlefs_portenta_H7
Características
Esta biblioteca é apenas um invólucro simples LittleFS para facilitar seu uso de pequenos flash a bordo do mbed portenta_h7 , usando arduinocore-mbed mbed_portenta core
O acesso ao sistema de arquivos usa APIs normais de POSIX ou MBED FileSystem APIs
Placas atualmente suportadas
- Portenta_H7 placas como Portenta_H7 Rev2 ABX00042, etc., usando Arduinocore-mbed_portenta Core
Pré -requisitos
-
Arduino IDE 1.8.19+ para Arduino. -
ArduinoCore-mbed mbed_portenta core 3.4.1+ para placas Arduino Portenta_H7 , como Portenta_H7 Rev2 ABX00042, etc.
Instalação
Use o gerente da biblioteca Arduino
A melhor e mais fácil maneira é usar Arduino Library Manager . Pesquise Littlefs_portenta_H7 e selecione / instale a versão mais recente. Você também pode usar este link para obter instruções mais detalhadas.
Instalação manual
Outra maneira de instalar é:
- Navegue para Littlefs_portenta_H7 .
- Faça o download do lançamento mais recente
LittleFS_Portenta_H7-main.zip . - Extrair o arquivo zip para
LittleFS_Portenta_H7-main Directory - Copie a pasta Whole
LittleFS_Portenta_H7-main para o diretório das bibliotecas Arduino, como ~/Arduino/libraries/ .
Vs código e plataforma
- Instale o código vs.
- Instale a plataforma
- Instale a biblioteca Littlefs_portenta_H7 usando o gerenciador de bibliotecas. Pesquise por Littlefs_portenta_h7 nas bibliotecas do Autor Platform.io
- Use o arquivo Platformio.ini incluído dos exemplos para garantir que todas as bibliotecas dependentes sejam instaladas automaticamente. Visite a documentação para as outras opções e exemplos no arquivo de configuração do projeto
Patches dos pacotes
1. Para placas portenta_h7 usando Arduino IDE em Linux
Para poder fazer upload do firmware para Portenta_H7 usando o Arduino IDE em Linux (Ubuntu, etc.) , você deve copiar o arquivo Portenta_post_install.sh no diretório mbed_portenta (~/.ararino15/packages/arduino/mais hardware/mbed_portenta/3.4.1/portente.
Em seguida, execute o seguinte comando usando sudo
$ cd ~/.arduino15/packages/arduino/hardware/mbed_portenta/3.4.1
$ chmod 755 portenta_post_install.sh
$ sudo ./portenta_post_install.sh
Isso criará o arquivo /etc/udev/rules.d/49-portenta_h7.rules da seguinte forma:
# Portenta H7 bootloader mode UDEV rules
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="035b", GROUP="plugdev", MODE="0666"
Supondo que a versão Core Arduinocore-MBED seja 3.4.1. Agora, apenas um arquivo deve ser copiado no diretório:
-
~/.arduino15/packages/arduino/hardware/mbed_portenta/3.4.1/portenta_post_install.sh
Sempre que uma nova versão estiver instalada, lembre -se de copiar esses arquivos no novo diretório da versão. Por exemplo, uma nova versão é x.yy.zz
Este arquivo deve ser copiado no diretório:
-
~/.arduino15/packages/arduino/hardware/mbed_portenta/x.yy.zz/portenta_post_install.sh
Exemplos
- Littlefs_Counting
- Littlefs_test
Exemplo Littlefs_test
| # Definir LFS_MBED_PORTENTA_H7_VERSION_MIN_TARGET " Littlefs_portenta_H7 v1.2.0 " |
| # Definir LFS_MBED_PORTENTA_H7_VERSION_MIN 1002000 |
| |
| # define _lfs_loglevel_ 1 |
| |
| # define force_reformat false |
| |
| # Incluir < Littlefs_portenta_H7.h > |
| |
| Littlefs_Mbed *myfs; |
| |
| uint32_t file_size_kb = 64 ; |
| |
| void readcharsfromfile ( const char * caminho) |
| { |
| Serial. print ( " readcharsFromFile: " ); Serial. impressão (caminho); |
| |
| Arquivo *arquivo = fopen (caminho, " r " ); |
| |
| if (arquivo) |
| { |
| Serial. println ( " => aberto ok " ); |
| } |
| outro |
| { |
| Serial. println ( " => aberto falhou " ); |
| retornar ; |
| } |
| |
| char c; |
| |
| enquanto ( verdadeiro ) |
| { |
| c = fgetc (arquivo); |
| |
| if ( feof (arquivo)) |
| { |
| quebrar ; |
| } |
| outro |
| Serial. impressão (c); |
| } |
| |
| fclose (arquivo); |
| } |
| |
| Void ReadFile ( Const Char * Path) |
| { |
| Serial. print ( " Arquivo de leitura: " ); Serial. impressão (caminho); |
| |
| Arquivo *arquivo = fopen (caminho, " r " ); |
| |
| if (arquivo) |
| { |
| Serial. println ( " => aberto ok " ); |
| } |
| outro |
| { |
| Serial. println ( " => aberto falhou " ); |
| retornar ; |
| } |
| |
| char c; |
| uint32_t numread = 1 ; |
| |
| while (numread) |
| { |
| numread = fret (( uint8_t *) & c, sizeof (c), 1 , arquivo); |
| |
| if (numread) |
| Serial. impressão (c); |
| } |
| |
| fclose (arquivo); |
| } |
| |
| void writefile ( const char * caminho, const char * mensagem, size_t mensagense) |
| { |
| Serial. print ( " Escrevendo o arquivo: " ); Serial. impressão (caminho); |
| |
| Arquivo *arquivo = fopen (caminho, " w " ); |
| |
| if (arquivo) |
| { |
| Serial. println ( " => aberto ok " ); |
| } |
| outro |
| { |
| Serial. println ( " => aberto falhou " ); |
| retornar ; |
| } |
| |
| if ( fwrite (( uint8_t *) mensagem, 1 , mensagens, arquivo)) |
| { |
| Serial. println ( " * escrevendo ok " ); |
| } |
| outro |
| { |
| Serial. println ( " * escrita falhou " ); |
| } |
| |
| fclose (arquivo); |
| } |
| |
| Void AppendFile ( const char * caminho, const char * mensagem, size_t mensagense) |
| { |
| Serial. print ( " arquivo de anexos: " ); Serial. impressão (caminho); |
| |
| Arquivo *arquivo = fopen (caminho, " a " ); |
| |
| if (arquivo) |
| { |
| Serial. println ( " => aberto ok " ); |
| } |
| outro |
| { |
| Serial. println ( " => aberto falhou " ); |
| retornar ; |
| } |
| |
| if ( fwrite (( uint8_t *) mensagem, 1 , mensagens, arquivo)) |
| { |
| Serial. println ( " * Anexando OK " ); |
| } |
| outro |
| { |
| Serial. println ( " * Appender falhou " ); |
| } |
| |
| fclose (arquivo); |
| } |
| |
| Void DeleteFile ( Const Char * Path) |
| { |
| Serial. print ( " Excluindo arquivo: " ); Serial. impressão (caminho); |
| |
| if ( remove (caminho) == 0 ) |
| { |
| Serial. println ( " => ok " ); |
| } |
| outro |
| { |
| Serial. println ( " => falhou " ); |
| retornar ; |
| } |
| } |
| |
| Void RenameFile ( const char * path1, const char * path2) |
| { |
| Serial. print ( " Renomear arquivo: " ); Serial. impressão (path1); |
| Serial. print ( " para: " ); Serial. impressão (path2); |
| |
| if ( renomear (path1, path2) == 0 ) |
| { |
| Serial. println ( " => ok " ); |
| } |
| outro |
| { |
| Serial. println ( " => falhou " ); |
| retornar ; |
| } |
| } |
| |
| Void testfileio ( const char * caminho) |
| { |
| Serial. print ( " Testando o arquivo de E/S com: " ); Serial. impressão (caminho); |
| |
| # Definir buff_size 512 |
| |
| estático uint8_t buf [buff_size]; |
| |
| Arquivo *arquivo = fopen (caminho, " w " ); |
| |
| if (arquivo) |
| { |
| Serial. println ( " => aberto ok " ); |
| } |
| outro |
| { |
| Serial. println ( " => aberto falhou " ); |
| retornar ; |
| } |
| |
| size_t i; |
| Serial. println ( " - escrita " ); |
| |
| uint32_t start = millis (); |
| |
| size_t resultado = 0 ; |
| |
| // Escreva um arquivo com file_size_kb |
| for (i = 0 ; i <arquivo_size_kb * 2 ; i ++) |
| { |
| resultado = fwrite (buf, buff_size, 1 , arquivo); |
| |
| if (resultado! = 1 ) |
| { |
| Serial. print ( " escreva resultado = " ); Serial. println (resultado); |
| Serial. print ( " Erro de gravação, i = " ); Serial. println (i); |
| |
| quebrar ; |
| } |
| } |
| |
| Serial. println ( " " ); |
| uint32_t end = millis () - start; |
| |
| Serial. impressão (i / 2 ); |
| Serial. print ( " kbytes escritos em (ms) " ); |
| Serial. println (final); |
| |
| fclose (arquivo); |
| |
| printline (); |
| |
| // /////////////////////////////////////////////////////////////// |
| |
| arquivo = fopen (caminho, " r " ); |
| |
| start = millis (); |
| end = start; |
| i = 0 ; |
| |
| if (arquivo) |
| { |
| start = millis (); |
| Serial. println ( " - leitura " ); |
| |
| resultado = 0 ; |
| |
| fseek (arquivo, 0 , Seek_set); |
| |
| // Leia um arquivo com file_size_kb |
| for (i = 0 ; i <arquivo_size_kb * 2 ; i ++) |
| { |
| resultado = fret (buf, buff_size, 1 , arquivo); |
| |
| if (resultado! = 1 ) |
| { |
| Serial. print ( " Leia resultado = " ); Serial. println (resultado); |
| Serial. print ( " Leia o erro, i = " ); Serial. println (i); |
| |
| quebrar ; |
| } |
| } |
| |
| Serial. println ( " " ); |
| end = millis () - start; |
| |
| Serial. imprimir ((i * buff_size) / 1024 ); |
| Serial. print ( " Kbytes leia em (ms) " ); |
| Serial. println (final); |
| |
| fclose (arquivo); |
| } |
| outro |
| { |
| Serial. println ( " - falhou ao abrir o arquivo para leitura " ); |
| } |
| } |
| |
| Void PrintLine () |
| { |
| Serial. println ( " ====================================================== ); |
| } |
| |
| configuração void () |
| { |
| Serial. começar ( 115200 ); |
| enquanto (! Serial) |
| |
| atraso ( 1000 ); |
| |
| Serial. imprimir ( " n iniciar Littlefs_test on " ); Serial. println (board_name); |
| Serial. println (LFS_MBED_PORTENTA_H7_VERSION); |
| |
| # se definido (LFS_MBED_PORTENTA_H7_VERSION_MIN) |
| if (LFS_MBED_PORTENTA_H7_VERSION_INT <LFS_MBED_PORTENTA_H7_VERSION_MIN) |
| { |
| Serial. print ( " Aviso. Deve usar este exemplo na versão igual ou posterior a: " ); |
| Serial. println (LFS_MBED_PORTENTA_H7_VERSION_MIN_TARGET); |
| } |
| # endif |
| |
| myfs = new Littlefs_Mbed (); |
| |
| if (! myfs-> init ()) |
| { |
| Serial. println ( " Littlefs Mount Falha " ); |
| |
| retornar ; |
| } |
| |
| char filename1 [] = mbed_littlefs_file_prefix " /hello1.txt " ; |
| char filename2 [] = mbed_littlefs_file_prefix " /hello2.txt " ; |
| |
| Char message [] = " Hello from " Board_name " n " ; |
| |
| printline (); |
| writefile (filename1, mensagem, sizeof (mensagem)); |
| printline (); |
| readfile (nome do arquivo1); |
| printline (); |
| |
| ApndendFile (FileName1, Mensagem, Sizeof (Mensagem)); |
| printline (); |
| readfile (nome do arquivo1); |
| printline (); |
| |
| renamefile (FILENAME1, FILENAME2); |
| printline (); |
| readcharsFromFile (FileName2); |
| printline (); |
| |
| DeleteFile (FileName2); |
| printline (); |
| ReadFile (FileName2); |
| printline (); |
| |
| testfileio (nome do arquivo1); |
| printline (); |
| testfileio (nome do arquivo2); |
| printline (); |
| deletefile (nome do arquivo1); |
| printline (); |
| DeleteFile (FileName2); |
| printline (); |
| |
| Serial. println ( " n teste completo " ); |
| } |
| |
| Void Loop () |
| { |
| } |
Amostras de saída do terminal de depuração
1. Littlefs_Counting em Portenta_H7_M7
A seguir, é apresentado a saída do terminal de amostra ao executar o exemplo Littlefs_Counting no mbed Portenta_H7_M7
1.1 Primeira execução
Start LittleFS_Counting on PORTENTA_H7_M7
LittleFS_Portenta_H7 v1 .2.0
[LFS] Flash Size : (KB) = 2048.00
[LFS] FlashIAP Start Address: = 0x0x8080000
[LFS] LittleFS size (KB) = 1536.00
[LFS] LittleFS Mount OK
Times have been run = 1
=> Open to write OK
1.2 após a redefinição
Start LittleFS_Counting on PORTENTA_H7_M7
LittleFS_Portenta_H7 v1 .2.0
[LFS] Flash Size : (KB) = 2048.00
[LFS] FlashIAP Start Address: = 0x0x8080000
[LFS] LittleFS size (KB) = 1536.00
[LFS] LittleFS Mount OK
=> Open to read OK
Times have been run = 2
=> Open to write OK
2. Littlefs_test em Portenta_H7_M7
A seguir, é apresentado a saída do terminal de amostra ao executar o exemplo Littlefs_test no mbed Portenta_H7_M7
Start LittleFS_Test on PORTENTA_H7_M7
LittleFS_Portenta_H7 v1 .2.0
[LFS] Flash Size : (KB) = 2048.00
[LFS] FlashIAP Start Address: = 0x0x8080000
[LFS] LittleFS size (KB) = 1536.00
[LFS] LittleFS Mount OK
====================================================
Writing file: /littlefs/hello1.txt => Open OK
* Writing OK
====================================================
Reading file: /littlefs/hello1.txt => Open OK
Hello from PORTENTA_H7_M7
====================================================
Appending file: /littlefs/hello1.txt => Open OK
* Appending OK
====================================================
Reading file: /littlefs/hello1.txt => Open OK
Hello from PORTENTA_H7_M7
Hello from PORTENTA_H7_M7
====================================================
Renaming file: /littlefs/hello1.txt to: /littlefs/hello2.txt => OK
====================================================
readCharsFromFile: /littlefs/hello2.txt => Open OK
Hello from PORTENTA_H7_M7
Hello from PORTENTA_H7_M7
====================================================
Deleting file: /littlefs/hello2.txt => OK
====================================================
Reading file: /littlefs/hello2.txt => Open Failed
====================================================
Testing file I/O with: /littlefs/hello1.txt => Open OK
- writing
64 Kbytes written in (ms) 1077
====================================================
- reading
384 Kbytes read in (ms) 0
====================================================
Testing file I/O with: /littlefs/hello2.txt => Open OK
- writing
64 Kbytes written in (ms) 1003
====================================================
- reading
64 Kbytes read in (ms) 0
====================================================
Deleting file: /littlefs/hello1.txt => OK
====================================================
Deleting file: /littlefs/hello2.txt => OK
====================================================
Depurar
A depuração é ativada por padrão no Serial.
Você também pode alterar o nível de depuração ( LFS_Loglevel ) de 0 para 4
# define LFS_DEBUG_OUTPUT Serial
// These define's must be placed at the beginning before #include "LittleFS_Portenta_H7.h"
// _LFS_LOGLEVEL_ from 0 to 4
# define _LFS_LOGLEVEL_ 0
Solução de problemas
Se você receber erros de compilação, na maioria das vezes, pode ser necessário instalar uma versão mais recente do núcleo para as placas Arduino.
Às vezes, a biblioteca só funcionará se você atualizar o núcleo da placa para a versão mais recente, porque estou usando funções recém -adicionadas.
Problemas
Envie questões para: Littlefs_portenta_h7 questões
PENDÊNCIA
- Procure por bug e melhoria.
FEITO
- Wrapper Basic Littlefs para Portenta_H7 , usando Arduinocore-mbed mbed_portenta Core
- Adicione a string de versão
- Adicione o índice
- Reduza o tamanho de
LittleFS para 1024kb - Corrija o erro do vinculador
multiple-definitions - Adicione astyle usando o estilo
allman . Restyle a biblioteca
Contribuições e obrigado
Muito obrigado a todos pela reportagem de bugs, novos recursos sugerindo, testando e contribuindo para o desenvolvimento desta biblioteca.
Contribuindo
Se você deseja contribuir com este projeto:
- Relatar bugs e erros
- Peça aprimoramentos
- Crie problemas e puxe solicitações
- Conte a outras pessoas sobre esta biblioteca
Licença
- A biblioteca está licenciada sob GPLV3
Direitos autorais
Copyright (C) 2021- Khoi Hoang