Inclut maintenant le "disque" dans le chemin du fichier, qui permet d'écrire sur une clé même si elle est banchée au HUB. Ou d'écrire sur deux clés (non testé)
This commit is contained in:
parent
fd309792e9
commit
2f051541cc
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
build/
|
36
.vscode/c_cpp_properties.json
vendored
Normal file
36
.vscode/c_cpp_properties.json
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
{
|
||||
"env": {
|
||||
"myDefaultIncludePath": [
|
||||
"${workspaceFolder}",
|
||||
"${workspaceFolder}/build",
|
||||
"${workspaceFolder}/build/generated/pico_base",
|
||||
"${env:PICO_SDK_PATH}/src/**/include",
|
||||
"${env:PICO_SDK_PATH}/lib/**/src",
|
||||
"${workspaceFolder}/lib/source"
|
||||
|
||||
],
|
||||
"myCompilerPath": "/usr/bin/arm-none-eabi-gcc"
|
||||
},
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Linux",
|
||||
"intelliSenseMode": "linux-gcc-arm",
|
||||
"includePath": [
|
||||
"${myDefaultIncludePath}",
|
||||
"${workspaceFolder}/build/"
|
||||
],
|
||||
"compilerPath": "/usr/bin/arm-none-eabi-gcc",
|
||||
"cStandard": "c11",
|
||||
"cppStandard": "c++17",
|
||||
"browse": {
|
||||
"path": [
|
||||
"${workspaceFolder}"
|
||||
],
|
||||
"limitSymbolsToIncludedHeaders": true,
|
||||
"databaseFilename": ""
|
||||
},
|
||||
"configurationProvider": "ms-vscode.cmake-tools"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
9
.vscode/settings.json
vendored
Normal file
9
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"board.h": "c",
|
||||
"tusb.h": "c",
|
||||
"inttypes.h": "c",
|
||||
"stdlib.h": "c",
|
||||
"cdefs.h": "c"
|
||||
}
|
||||
}
|
25
.vscode/tasks.json
vendored
Normal file
25
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"tasks": [
|
||||
{
|
||||
"type": "shell",
|
||||
"command": "cd build; cmake ../ -DLOG=2; make Flash",
|
||||
"label": "Flash with LOG=2",
|
||||
"problemMatcher": [],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"command": "cd build; cmake ../ ; make Flash",
|
||||
"label": "CMake & Make & Flash",
|
||||
"problemMatcher": [],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"version": "2.0.0"
|
||||
}
|
23
Journal.txt
23
Journal.txt
@ -2,33 +2,12 @@ Journal USB Host
|
||||
|
||||
6 juin 2025
|
||||
|
||||
On arrive à activer les logs, mais avec 2 manipulations :
|
||||
On arrive à activer les logs, mais avec 1 manipulations, comme indiqué dans la documentation, mais avec la dernière version.
|
||||
|
||||
tasks.json
|
||||
----------
|
||||
|
||||
"command": "cd build; cmake ../ -DCMAKE_BUILD_TYPE=Debug -DLOG=2; make Flash",
|
||||
|
||||
diff --git a/hw/bsp/rp2040/family.cmake b/hw/bsp/rp2040/family.cmake
|
||||
index 1eab95304..278e7e152 100644
|
||||
--- a/hw/bsp/rp2040/family.cmake
|
||||
+++ b/hw/bsp/rp2040/family.cmake
|
||||
@@ -49,13 +49,13 @@ if (NOT TARGET _rp2040_family_inclusion_marker)
|
||||
set(TINYUSB_DEBUG_LEVEL 0)
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
message("Compiling TinyUSB with CFG_TUSB_DEBUG=1")
|
||||
- set(TINYUSB_DEBUG_LEVEL 1)
|
||||
+ set(TINYUSB_DEBUG_LEVEL 2)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(tinyusb_common_base INTERFACE
|
||||
CFG_TUSB_MCU=OPT_MCU_RP2040
|
||||
CFG_TUSB_OS=OPT_OS_PICO
|
||||
- #CFG_TUSB_DEBUG=${TINYUSB_DEBUG_LEVEL}
|
||||
+ CFG_TUSB_DEBUG=${TINYUSB_DEBUG_LEVEL}
|
||||
)
|
||||
|
||||
#------------------------------------
|
||||
|
||||
|
||||
Doc de FsFat
|
||||
|
@ -166,7 +166,7 @@
|
||||
/ Drive/Volume Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define FF_VOLUMES 1
|
||||
#define FF_VOLUMES 10
|
||||
/* Number of volumes (logical drives) to be used. (1-10) */
|
||||
|
||||
|
||||
|
80
msc_app.c
80
msc_app.c
@ -26,8 +26,8 @@
|
||||
#include "tusb.h"
|
||||
#include "ff.h"
|
||||
#include "diskio.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "pico/time.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
|
||||
@ -38,10 +38,16 @@ static scsi_inquiry_resp_t inquiry_resp;
|
||||
static FATFS fatfs[CFG_TUH_DEVICE_MAX]; // for simplicity only support 1 LUN per device
|
||||
static volatile bool _disk_busy[CFG_TUH_DEVICE_MAX];
|
||||
|
||||
bool file_accessible = false;
|
||||
FIL fp;
|
||||
|
||||
void log_to_usb(const char * message);
|
||||
|
||||
bool inquiry_complete_cb(uint8_t dev_addr, tuh_msc_complete_data_t const * cb_data)
|
||||
{
|
||||
msc_cbw_t const* cbw = cb_data->cbw;
|
||||
msc_csw_t const* csw = cb_data->csw;
|
||||
FRESULT error;
|
||||
|
||||
if (csw->status != 0)
|
||||
{
|
||||
@ -66,33 +72,78 @@ bool inquiry_complete_cb(uint8_t dev_addr, tuh_msc_complete_data_t const * cb_da
|
||||
uint8_t const drive_num = dev_addr-1;
|
||||
char drive_path[3] = "0:";
|
||||
drive_path[0] += drive_num;
|
||||
if ( f_mount(&fatfs[drive_num], "", 1) != FR_OK )
|
||||
printf("dev_addr: %d\ndrive_num: %d\n", dev_addr, drive_num);
|
||||
error = f_mount(&fatfs[drive_num], drive_path, 1);
|
||||
if ( error != FR_OK )
|
||||
{
|
||||
printf("FatFs mount failed\n");
|
||||
printf("FatFs mount failed, error: %d\n", error);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
FIL fp;
|
||||
|
||||
const char buffer[]= "Ceci est le test de Poivron Robotique\n";
|
||||
int nb_byte_witten;
|
||||
char big_buffer[0x1000]; // 4 ko
|
||||
char big_big_buffer[0x10000]; // 16 ko
|
||||
int nb_byte_written;
|
||||
absolute_time_t current_time, start_time;
|
||||
char filepath[50];
|
||||
filepath[0] = drive_path[0];
|
||||
filepath[1] = ':';
|
||||
filepath[2] = '\0';
|
||||
strcat(filepath, "Poivron.txt");
|
||||
printf("filepath:%s\n", filepath);
|
||||
|
||||
FRESULT error;
|
||||
error = f_open(&fp, "Poivron.txt", FA_WRITE | FA_OPEN_ALWAYS);
|
||||
|
||||
error = f_open(&fp, filepath, FA_WRITE | FA_OPEN_ALWAYS);
|
||||
if(error){
|
||||
printf("f_open: error %d\n", error);
|
||||
}
|
||||
if(f_write(&fp, buffer, strlen(buffer), &nb_byte_witten)){
|
||||
printf("f_write: error %d\n", error);
|
||||
}else{
|
||||
printf("Ecris: %d octets\n", nb_byte_witten);
|
||||
file_accessible = true;
|
||||
|
||||
// Ecrit petit buffer
|
||||
log_to_usb(buffer);
|
||||
// Ecrit gros buffer
|
||||
int size = 0;
|
||||
big_buffer[0]= '\0';
|
||||
while(size + strlen(buffer) < 0x1000){
|
||||
strcat(big_buffer, buffer);
|
||||
size += strlen(buffer);
|
||||
}
|
||||
log_to_usb(big_buffer);
|
||||
|
||||
// Ecrit très gros buffer
|
||||
size = 0;
|
||||
big_big_buffer[0]= '\0';
|
||||
while(size + strlen(buffer) < 0x10000){
|
||||
strcat(big_buffer, buffer);
|
||||
size += strlen(buffer);
|
||||
}
|
||||
log_to_usb(big_big_buffer);
|
||||
|
||||
|
||||
|
||||
f_close(&fp);
|
||||
printf("Fichier Poivron.txt cree avec succes\n");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void log_to_usb(const char * message){
|
||||
int nb_byte_written;
|
||||
absolute_time_t current_time, start_time;
|
||||
start_time = get_absolute_time();
|
||||
FRESULT error;
|
||||
if(file_accessible){
|
||||
error = f_write(&fp, message, strlen(message), &nb_byte_written);
|
||||
if(error){
|
||||
printf("f_write: error %d\n", error);
|
||||
return;
|
||||
}
|
||||
f_sync(&fp);
|
||||
current_time = get_absolute_time();
|
||||
printf("Ecrit: %d octets en %llu us\n", nb_byte_written, current_time - start_time);
|
||||
}
|
||||
}
|
||||
|
||||
//------------- IMPLEMENTATION -------------//
|
||||
void tuh_msc_mount_cb(uint8_t dev_addr)
|
||||
{
|
||||
@ -104,6 +155,7 @@ void tuh_msc_mount_cb(uint8_t dev_addr)
|
||||
|
||||
void tuh_msc_umount_cb(uint8_t dev_addr)
|
||||
{
|
||||
file_accessible = false;
|
||||
(void) dev_addr;
|
||||
printf("A MassStorage device is unmounted\r\n");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user