Просмотр исходного кода

fix build with rp2040 and rx65

hathach 3 лет назад
Родитель
Сommit
47bc269b50

+ 6 - 1
examples/host/msc_file_explorer/CMakeLists.txt

@@ -16,11 +16,16 @@ add_executable(${PROJECT})
 target_sources(${PROJECT} PUBLIC
         ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
         ${CMAKE_CURRENT_SOURCE_DIR}/src/msc_app.c
+        ${TOP}/lib/fatfs/source/ff.c
+        ${TOP}/lib/fatfs/source/ffsystem.c
+        ${TOP}/lib/fatfs/source/ffunicode.c
         )
 
 # Example include
 target_include_directories(${PROJECT} PUBLIC
         ${CMAKE_CURRENT_SOURCE_DIR}/src
+        ${TOP}/lib/fatfs/source
+        ${TOP}/lib/embedded-cli
         )
 
 # Configure compilation flags and libraries for the example... see the corresponding function
@@ -30,7 +35,7 @@ family_configure_host_example(${PROJECT})
 # For rp2040, un-comment to enable pico-pio-usb
 family_add_pico_pio_usb(${PROJECT})
 
-# due to warnings from Pico-PIO-USB
+# due to warnings from Pico-PIO-USB and fatfs
 target_compile_options(${PROJECT} PUBLIC
         -Wno-error=shadow
         -Wno-error=cast-align

+ 8 - 8
examples/host/msc_file_explorer/src/msc_app.c

@@ -205,7 +205,7 @@ DRESULT disk_read (
 	uint8_t const lun = 0;
 
 	_disk_busy[pdrv] = true;
-	tuh_msc_read10(dev_addr, lun, buff, sector, count, disk_io_complete);
+	tuh_msc_read10(dev_addr, lun, buff, sector, (uint16_t) count, disk_io_complete);
 	wait_for_disk_io(pdrv);
 
 	return RES_OK;
@@ -224,7 +224,7 @@ DRESULT disk_write (
 	uint8_t const lun = 0;
 
 	_disk_busy[pdrv] = true;
-	tuh_msc_write10(dev_addr, lun, buff, sector, count, disk_io_complete);
+	tuh_msc_write10(dev_addr, lun, buff, sector, (uint16_t) count, disk_io_complete);
 	wait_for_disk_io(pdrv);
 
 	return RES_OK;
@@ -247,11 +247,11 @@ DRESULT disk_ioctl (
       return RES_OK;
 
     case GET_SECTOR_COUNT:
-      *((DWORD*) buff) = tuh_msc_get_block_count(dev_addr, lun);
+      *((DWORD*) buff) = (WORD) tuh_msc_get_block_count(dev_addr, lun);
       return RES_OK;
 
     case GET_SECTOR_SIZE:
-      *((WORD*) buff) = tuh_msc_get_block_size(dev_addr, lun);
+      *((WORD*) buff) = (WORD) tuh_msc_get_block_size(dev_addr, lun);
       return RES_OK;
 
     case GET_BLOCK_SIZE:
@@ -380,10 +380,10 @@ void cli_cmd_cat(EmbeddedCli *cli, char *args, void *context)
     }else
     {
       uint8_t buf[512];
-      size_t count = 0;
+      UINT count = 0;
       while ( (FR_OK == f_read(&fi, buf, sizeof(buf), &count)) && (count > 0) )
       {
-        for(size_t c = 0; c < count; c++)
+        for(UINT c = 0; c < count; c++)
         {
           const char ch = buf[c];
           if (isprint(ch) || iscntrl(ch))
@@ -455,10 +455,10 @@ void cli_cmd_cp(EmbeddedCli *cli, char *args, void *context)
   }else
   {
     uint8_t buf[512];
-    size_t rd_count = 0;
+    UINT rd_count = 0;
     while ( (FR_OK == f_read(&f_src, buf, sizeof(buf), &rd_count)) && (rd_count > 0) )
     {
-      size_t wr_count = 0;
+      UINT wr_count = 0;
 
       if ( FR_OK != f_write(&f_dst, buf, rd_count, &wr_count) )
       {

+ 2 - 1
examples/make.mk

@@ -113,7 +113,8 @@ CFLAGS += \
   
 # Debugging/Optimization
 ifeq ($(DEBUG), 1)
-  CFLAGS += -Og
+  CFLAGS += -O0
+  NO_LTO = 1
 else
   CFLAGS += $(CFLAGS_OPTIMIZED)
 endif