You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2022/05/04 11:47:34 UTC
[GitHub] [mynewt-core] kasjer opened a new pull request, #2828: usb msc fat view
kasjer opened a new pull request, #2828:
URL: https://github.com/apache/mynewt-core/pull/2828
MSC FAT view aims to allow firmware upgrade over USB when Mynewt device is visible as FAT disk.
MSC FAT View may be included in bootloader or application.
When it's part of the application new image written to device goes to SLOT1 and bootloader will
verify it and swap with current image.
New image will be confirmed (this can be disabled) on first access from host over USB.
MSC FAT view also allow to create custom files presented in file system that can be used to see
various aspects of running image.
By default README.TXT and MYNEWT.HTM are added.
Optionally 'Huge file' can show up that can be used for performance tests.
Optionally 'SLOT0.HEX' can show up with textual content of SLOT0.
Optionally 'FIRMWARE.IMG' can show up with binary content of SLOT0.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [mynewt-core] utzig commented on pull request #2828: usb msc fat view
Posted by GitBox <gi...@apache.org>.
utzig commented on PR #2828:
URL: https://github.com/apache/mynewt-core/pull/2828#issuecomment-1126282459
<!-- style-bot -->
## Style check summary
### Our coding style is [here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
#### hw/usb/tinyusb/msc_fat_view/src/msc_fat_view.c
<details>
```diff
@@ -49,9 +49,9 @@
#define SECTOR_SIZE 512
#define SECTORS_PER_CLUSTER (MYNEWT_VAL(MSC_FAT_VIEW_SECTORS_PER_CLUSTER))
-#define CLUSTER_SIZE ((SECTOR_SIZE) * (SECTORS_PER_CLUSTER))
-
-#define CLUSTER_COUNT ((SECTOR_COUNT + ((SECTORS_PER_CLUSTER) - 1)) / (SECTORS_PER_CLUSTER))
+#define CLUSTER_SIZE ((SECTOR_SIZE) *(SECTORS_PER_CLUSTER))
+
+#define CLUSTER_COUNT ((SECTOR_COUNT + ((SECTORS_PER_CLUSTER) -1)) / (SECTORS_PER_CLUSTER))
#if CLUSTER_COUNT < 4085
#define FAT_TYPE FAT_TYPE_FAT12
@@ -66,7 +66,7 @@
#define FAT_ENTRY_SIZE FAT_TYPE
#define FAT_ENTRY_COUNT ((SECTOR_COUNT) / (SECTORS_PER_CLUSTER))
-#define FAT_BYTES ((FAT_ENTRY_COUNT) * (FAT_ENTRY_SIZE) / 8)
+#define FAT_BYTES ((FAT_ENTRY_COUNT) *(FAT_ENTRY_SIZE) / 8)
#define FAT_SECTOR_COUNT ((FAT_BYTES + SECTOR_SIZE - 1) / (SECTOR_SIZE))
#define SECTOR_BIT_COUNT ((SECTOR_SIZE) * 8)
@@ -74,7 +74,7 @@
#define ROOT_SECTOR_COUNT 1
#define FAT_FIRST_SECTOR 1
-#define FAT_ROOT_DIR_FIRST_SECTOR ((FAT_FIRST_SECTOR) + (FAT_SECTOR_COUNT) * (FAT_COUNT))
+#define FAT_ROOT_DIR_FIRST_SECTOR ((FAT_FIRST_SECTOR) + (FAT_SECTOR_COUNT) *(FAT_COUNT))
#define FAT_CLUSTER2_FIRST_SECTOR ((FAT_ROOT_DIR_FIRST_SECTOR) + (ROOT_SECTOR_COUNT))
#if SECTOR_COUNT > 65535
@@ -112,8 +112,7 @@
#define HUGE_FILE_SIZE ((MYNEWT_VAL(MSC_FAT_VIEW_DISK_SIZE) * 1024) - 2000000)
#endif
-struct TU_ATTR_PACKED boot_sector_start
-{
+struct TU_ATTR_PACKED boot_sector_start {
uint8_t jmp[3];
char os_name[8];
uint16_t bytes_per_sector;
@@ -291,8 +290,8 @@
};
static const char readme_text[] = "This device runs "
- MYNEWT_VAL(MSC_FAT_VIEW_DEFAULT_README_APP_NAME) " on "
- MYNEWT_VAL(BSP_NAME);
+ MYNEWT_VAL(MSC_FAT_VIEW_DEFAULT_README_APP_NAME) " on "
+ MYNEWT_VAL(BSP_NAME);
#if defined MYNEWT_VAL_REPO_VERSION_APACHE_MYNEWT_CORE
#define REPO_VERSION_APACHE_MYNEWT_CORE MYNEWT_VAL(REPO_VERSION_APACHE_MYNEWT_CORE)
@@ -717,7 +716,7 @@
fat_chain_t *limit = fat_chains + fat_chain_count + 1;
fat_chain_count++;
- for (;limit > chain; --limit) {
+ for (; limit > chain; --limit) {
limit[0] = limit[-1];
}
}
@@ -907,7 +906,8 @@
if (file_size > 0) {
root_dir[entry_ix].first_cluster = alloc_cluster_chain(0, cluster_count_from_bytes(file_size));
}
- MSC_FAT_VIEW_LOG_DEBUG("%s size %d, cluster %d (%d)\n", file->name, file_size, root_dir[entry_ix].first_cluster, cluster_count_from_bytes(file_size));
+ MSC_FAT_VIEW_LOG_DEBUG("%s size %d, cluster %d (%d)\n", file->name, file_size, root_dir[entry_ix].first_cluster, cluster_count_from_bytes(
+ file_size));
}
static dir_entry_t *
@@ -916,7 +916,7 @@
dir_entry_t *entry = root_dir;
dir_entry_t *limit = root_dir + root_dir_entry_count;
- for (;entry < limit; ++entry) {
+ for (; entry < limit; ++entry) {
if (strcmp(entry->file->name, name) == 0) {
return entry;
}
@@ -949,7 +949,8 @@
}
static void
-msc_fat_view_put_cluster_bits(uint8_t *buffer, uint32_t sector_start_bit, int cluster_bit_offset, uint32_t next_cluster)
+msc_fat_view_put_cluster_bits(uint8_t *buffer, uint32_t sector_start_bit, int cluster_bit_offset,
+ uint32_t next_cluster)
{
int ix;
int drop_bits;
@@ -1163,7 +1164,9 @@
}
}
if (add_tilda) {
- for (i = 0; i < 6 && short_name[i] != ' '; ++i) ;
+ for (i = 0; i < 6 && short_name[i] != ' '; ++i) {
+ ;
+ }
short_name[i++] = '~';
/* Not name should be checked for duplicates */
short_name[i] = '1';
@@ -1378,7 +1381,7 @@
MSC_FAT_VIEW_LOG_INFO("Write root dir sector %d\n", sector);
- for (;entry < limit; ++entry) {
+ for (; entry < limit; ++entry) {
if (entry->bytes[0] == 0xe5) {
continue;
}
@@ -1401,8 +1404,7 @@
}
}
/* Exclude directories and volume names */
- if ((entry->attr & (FAT_FILE_ENTRY_ATTRIBUTE_DIRECTORY | FAT_FILE_ENTRY_ATTRIBUTE_LABEL)) == 0)
- {
+ if ((entry->attr & (FAT_FILE_ENTRY_ATTRIBUTE_DIRECTORY | FAT_FILE_ENTRY_ATTRIBUTE_LABEL)) == 0) {
if (msc_fat_view_short_name_checksum(entry->name) != checksum) {
for (i = 0; i < 8 && entry->name[i] != ' '; ++i) {
name[i] = entry->name[i];
@@ -1420,9 +1422,11 @@
if (file_entry == NULL) {
/* new file just showed up in root directory */
msc_fat_view_handle_new_file(entry, name);
-// if (unallocated_write.write_status < 0) {
-// res = -1;
-// }
+/*
+ if (unallocated_write.write_status < 0) {
+ res = -1;
+ }
+ */
}
}
}
@@ -1514,7 +1518,8 @@
if (dir_entry == NULL) {
res = msc_fat_view_write_unallocated_sector(sector, buffer);
} else {
- res = msc_fat_view_write_file_sector(dir_entry, sector_in_cluster + cluster_in_chain * SECTORS_PER_CLUSTER, buffer);
+ res = msc_fat_view_write_file_sector(dir_entry, sector_in_cluster + cluster_in_chain * SECTORS_PER_CLUSTER,
+ buffer);
}
return res;
@@ -1610,7 +1615,7 @@
* Application update block count and block size
*/
void
-tud_msc_capacity_cb(uint8_t lun, uint32_t* block_count, uint16_t* block_size)
+tud_msc_capacity_cb(uint8_t lun, uint32_t * block_count, uint16_t * block_size)
{
(void)lun;
@@ -1654,7 +1659,7 @@
* Copy disk's data to buffer (up to bufsize) and return number of copied bytes.
*/
int32_t
-tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize)
+tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void * buffer, uint32_t bufsize)
{
(void)lun;
(void)offset;
@@ -1674,7 +1679,7 @@
* Process data in buffer to disk's storage and return number of written bytes
*/
int32_t
-tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize)
+tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t * buffer, uint32_t bufsize)
{
int32_t res;
MSC_FAT_VIEW_LOG_DEBUG("SCSI WRITE10 %d, %d, %d\n", (int)lba, (int)offset, (int)bufsize);
@@ -1709,7 +1714,7 @@
* - READ10 and WRITE10 has their own callbacks
*/
int32_t
-tud_msc_scsi_cb(uint8_t lun, uint8_t const scsi_cmd[16], void* buffer, uint16_t bufsize)
+tud_msc_scsi_cb(uint8_t lun, uint8_t const scsi_cmd[16], void * buffer, uint16_t bufsize)
{
void const *response = NULL;
int32_t resplen = 0;
```
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [mynewt-core] utzig commented on pull request #2828: usb msc fat view
Posted by GitBox <gi...@apache.org>.
utzig commented on PR #2828:
URL: https://github.com/apache/mynewt-core/pull/2828#issuecomment-1126541693
<!-- style-bot -->
## Style check summary
### Our coding style is [here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
#### hw/usb/tinyusb/msc_fat_view/src/msc_fat_view.c
<details>
```diff
@@ -49,9 +49,9 @@
#define SECTOR_SIZE 512
#define SECTORS_PER_CLUSTER (MYNEWT_VAL(MSC_FAT_VIEW_SECTORS_PER_CLUSTER))
-#define CLUSTER_SIZE ((SECTOR_SIZE) * (SECTORS_PER_CLUSTER))
-
-#define CLUSTER_COUNT ((SECTOR_COUNT + ((SECTORS_PER_CLUSTER) - 1)) / (SECTORS_PER_CLUSTER))
+#define CLUSTER_SIZE ((SECTOR_SIZE) *(SECTORS_PER_CLUSTER))
+
+#define CLUSTER_COUNT ((SECTOR_COUNT + ((SECTORS_PER_CLUSTER) -1)) / (SECTORS_PER_CLUSTER))
#if CLUSTER_COUNT < 4085
#define FAT_TYPE FAT_TYPE_FAT12
@@ -66,7 +66,7 @@
#define FAT_ENTRY_SIZE FAT_TYPE
#define FAT_ENTRY_COUNT ((SECTOR_COUNT) / (SECTORS_PER_CLUSTER))
-#define FAT_BYTES ((FAT_ENTRY_COUNT) * (FAT_ENTRY_SIZE) / 8)
+#define FAT_BYTES ((FAT_ENTRY_COUNT) *(FAT_ENTRY_SIZE) / 8)
#define FAT_SECTOR_COUNT ((FAT_BYTES + SECTOR_SIZE - 1) / (SECTOR_SIZE))
#define SECTOR_BIT_COUNT ((SECTOR_SIZE) * 8)
@@ -74,7 +74,7 @@
#define ROOT_SECTOR_COUNT 1
#define FAT_FIRST_SECTOR 1
-#define FAT_ROOT_DIR_FIRST_SECTOR ((FAT_FIRST_SECTOR) + (FAT_SECTOR_COUNT) * (FAT_COUNT))
+#define FAT_ROOT_DIR_FIRST_SECTOR ((FAT_FIRST_SECTOR) + (FAT_SECTOR_COUNT) *(FAT_COUNT))
#define FAT_CLUSTER2_FIRST_SECTOR ((FAT_ROOT_DIR_FIRST_SECTOR) + (ROOT_SECTOR_COUNT))
#if SECTOR_COUNT > 65535
@@ -949,7 +949,8 @@
}
static void
-msc_fat_view_put_cluster_bits(uint8_t *buffer, uint32_t sector_start_bit, int cluster_bit_offset, uint32_t next_cluster)
+msc_fat_view_put_cluster_bits(uint8_t *buffer, uint32_t sector_start_bit, int cluster_bit_offset,
+ uint32_t next_cluster)
{
int ix;
int drop_bits;
```
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [mynewt-core] utzig commented on pull request #2828: usb msc fat view
Posted by GitBox <gi...@apache.org>.
utzig commented on PR #2828:
URL: https://github.com/apache/mynewt-core/pull/2828#issuecomment-1126673113
<!-- style-bot -->
## Style check summary
### Our coding style is [here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
#### hw/usb/tinyusb/msc_fat_view/src/msc_fat_view.c
<details>
```diff
@@ -49,9 +49,9 @@
#define SECTOR_SIZE 512
#define SECTORS_PER_CLUSTER (MYNEWT_VAL(MSC_FAT_VIEW_SECTORS_PER_CLUSTER))
-#define CLUSTER_SIZE ((SECTOR_SIZE) * (SECTORS_PER_CLUSTER))
-
-#define CLUSTER_COUNT ((SECTOR_COUNT + ((SECTORS_PER_CLUSTER) - 1)) / (SECTORS_PER_CLUSTER))
+#define CLUSTER_SIZE ((SECTOR_SIZE) *(SECTORS_PER_CLUSTER))
+
+#define CLUSTER_COUNT ((SECTOR_COUNT + ((SECTORS_PER_CLUSTER) -1)) / (SECTORS_PER_CLUSTER))
#if CLUSTER_COUNT < 4085
#define FAT_TYPE FAT_TYPE_FAT12
@@ -66,7 +66,7 @@
#define FAT_ENTRY_SIZE FAT_TYPE
#define FAT_ENTRY_COUNT ((SECTOR_COUNT) / (SECTORS_PER_CLUSTER))
-#define FAT_BYTES ((FAT_ENTRY_COUNT) * (FAT_ENTRY_SIZE) / 8)
+#define FAT_BYTES ((FAT_ENTRY_COUNT) *(FAT_ENTRY_SIZE) / 8)
#define FAT_SECTOR_COUNT ((FAT_BYTES + SECTOR_SIZE - 1) / (SECTOR_SIZE))
#define SECTOR_BIT_COUNT ((SECTOR_SIZE) * 8)
@@ -74,7 +74,7 @@
#define ROOT_SECTOR_COUNT 1
#define FAT_FIRST_SECTOR 1
-#define FAT_ROOT_DIR_FIRST_SECTOR ((FAT_FIRST_SECTOR) + (FAT_SECTOR_COUNT) * (FAT_COUNT))
+#define FAT_ROOT_DIR_FIRST_SECTOR ((FAT_FIRST_SECTOR) + (FAT_SECTOR_COUNT) *(FAT_COUNT))
#define FAT_CLUSTER2_FIRST_SECTOR ((FAT_ROOT_DIR_FIRST_SECTOR) + (ROOT_SECTOR_COUNT))
#if SECTOR_COUNT > 65535
```
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [mynewt-core] kasjer merged pull request #2828: usb msc fat view
Posted by GitBox <gi...@apache.org>.
kasjer merged PR #2828:
URL: https://github.com/apache/mynewt-core/pull/2828
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org