Description: Bring up a USB Host with MSC capability, and store periodic data on it.
Equipment Needed in addition to previous test.
*) a converter cable from USB micro to USB Type A Host
*) A USB Flash drive
The stm32f4discovery board has "USB OTG FS with micro-AB connector".
This supports a USB Full Speed device to connect, and Nuttx drivers support a USB Host MSC capability - ie accessing a flash drive.
$ make menuconfig
System Type--> STM32 Peripheral Support-
[*] OTG FS
Device Drivers-->USB Host Driver Support
[*] Mass Storage Class Support
<exit><exit>
Board Selection--> #notice the following are set
(1024) USB host waiter stack size (NEW)
(100) USB host waiter task priority (NEW)
<exit>
System Type-->USB FS Host Configuration
(128) Rx Packet Size (NEW)
(96) Non-periodic Tx FIFO Size (NEW)
(128) Periodic Tx FIFO size (NEW)
(128) Descriptor Size (NEW)
[ ] Enable SOF interrupts (NEW)
#USB needs a work thread
RTOS Features-->Work queue support CONFIG_SCHED_WORKQUEU
[*] High priority (kernel) worker thread
CONFIG_SCHED_HPWORK
(224) High priority worker thread priority
(NEW)
(50000) High priority worker thread period
(NEW)
(2048) High priority worker thread stack size
(NEW)
<exit>.....<save>
RTOS Features -->Stack and Heap Information
(these values are arbitrarily increased to insure enough ram - FUT needs to be characterized with a stack inspection program some time)
(2048) Idle thread stack size
(4096) Main thread stack size
(2048) Minimum pthread stack size
(2048) Default pthread stack size
RTOS Features -->Stack and Heap Information
(these values are arbitrarily increased to insure enough ram - FUT needs to be characterized with a stack inspection program some time)
(2048) Idle thread stack size
(4096) Main thread stack size
(2048) Minimum pthread stack size
(2048) Default pthread stack size
$mknx.sh
size nuttx
text data bss dec hex filename
86204 308 6148 92660 169f4 nuttx
$stwr
on the stm32f4discovery
uttShell (NSH) NuttX-17.6
nsh>
nsh> ls dev
/dev:
console
null
rtc0
ttyS0
# Plug in a Flash drive through the microUSB to USB Type A Receptacle, and look for 'sda'
nsh> ls dev
/dev:
console
null
rtc0
sda
ttyS0
nsh>
#### Hurrah - its recognized the USB Flash drive.
mount -t vfat /dev/sda /usb0
nsh> ls
/:
dev/
proc/
usb0/
nsh> ls /usb0
/usb0:
System Volume Information/
LOST.DIR/
.....
#### WOW! Reading the directory ####
nsh> mkdir /usb0/tst1
#check if it writes to the directory
nsh> help > /usb0/tst1/h.txt
nsh> cat /usb0/tst1/h.txt
help usage: help [-v] [<cmd>]
[ dirname free mkfifo rm uname
? date help mkrd rmdir umount
basename dd hexdump mh set unset
break df kill mount sh usleep
cat echo ls mv sleep xd
cd exec mb mw test
cp exit mkdir ps time
cmp false mkfatfs pwd true
Builtin Apps:
# What meta info is there about the file? - but no date information
nsh> ls -lRs /usb0/tst1
/usb0/tst1:
-rw-rw-rw- 619 h.txt
nsh>
#Now reset the board, with the USB Host installed, verify the USB Host is recognized and writable.
NuttShell (NSH) NuttX-17.6
nsh> ls /dev
/dev:
console
null
rtc0
sda
ttyS0
nsh> mount -t vfat /dev/sda /usb0
nsh> ls /usb0/tst1
/usb0/tst1:
h.txt
nsh> rm /usb0/tst1/h.txt
nsh> ls /usb0/tst1
/usb0/tst1:
nsh>
#File is gone - so writeable.
# Ok - so lets write to these directories from an app. This requires using an examples application that can be redirected.
$make menuconfig
Application Configuration --->Examples
[*] "Hello, World!" example
(100) Hello task priority (NEW)
(2048) Hello stack size (NEW)
<save><ok><exit>...
$mknx.sh
$stwr
nsh> help
help usage: help [-v] [<cmd>]
[ dirname free mkfifo rm uname
? date help mkrd rmdir umount
basename dd hexdump mh set unset
break df kill mount sh usleep
cat echo ls mv sleep xd
cd exec mb mw test
cp exit mkdir ps time
cmp false mkfatfs pwd true
Builtin Apps:
hello
nsh> hello
Hello, World!!
nsh> mount -t vfat /dev/sda /usb0
nsh> ls
/:
dev/
proc/
usb0/
nsh> free > /usb0/tst1/f.txt
nsh> cat /usb0/tst1/f.txt
total used free largest
Mem: 189120 13552 175568 121392
nsh> hello > /usb0/tst1/h.txt
nsh> cat /usb0/tst1/h.txt
Hello, World!!
nsh>
nsh> hello >> /usb0/tst1/h.txt
nsh>
nsh> cat /usb0/tst1/h.txt
Hello, World!!
Hello, World!!
nsh>
Hello, World!!
nsh>
nsh> hello >> /usb0/tst1/h.txt
nsh>
nsh> cat /usb0/tst1/h.txt
Hello, World!!
Hello, World!!
nsh>
#Wowa - all working nicely (afterNuttx 17.7 or 17.6 afterJuly/7 - bugfix )
<tbd: modify a program to write periodic data to USB Flash>
No comments:
Post a Comment