Month: September 2019

ffmpeg conversion error: Could not find tag for codec pcm_s16be

I was trying to convert a big footage to h264 format using ffmpeg command:

$ ffmpeg -i C0005.MP4 -c:v libx264 -c:a copy C0005_H264.mp4

But it was returning this error:

Could not find tag for codec pcm_s16be in stream #1, codec not currently supported in container
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:0 --

After some searching I found some hints here:

https://ffmpeg.org/pipermail/libav-user/2016-January/008756.html

Oh yeah, we PCM 16-bit is not support by MP4 see: https://en.wikipedia.org/wiki/Comparison_of_video_container_formats, but it is strange because the original video as on MP4 container and I was just instructing ffmpeg to copy the audio. Too Lazy I will not search for it, but I think it is ffmpeg fault. If you find further info, please comment here.

I decided to use the AAC audio format instead copying the PCM format that was embedded in the video:

$ ffmpeg -i C0005.MP4 -c:v libx264 -c:a aac -strict experimental C0005_H264.mp4

And it worked fine!

Running NuttX on Arduino M0

NuttX has support to SAMD21 MCU and this is the MCU used on Arduino M0. Then I decided to add board support to Arduino M0 on NuttX mainline.

I used the Wemos SAMD21 M0 (a compatible Arduino M0 board), but you can use the original Arduino M0 or even the RobotDyn SAMD21 M0 board.

Enter inside NuttX directory, clear it and configure to use the arduino-m0:

$ cd nuttx
$ make distclean 
$ ./tools/configure.sh arduino-m0:nsh
Detected arm Architecture
Detected samd2l2 Chip
Copy files
Refreshing…

Compile it:

$ make

After compilation, confirm the binary was generated:

$ ls -l nuttx.bin 
-rwxr-xr-x 1 alan alan 43436 set 22 13:13 nuttx.bin

Connect J-Link to SWD (EDBG) pin header and run and flash the firmware:

$ sudo JLinkExe -device ATSAML21G18 -if SWD

SEGGER J-Link Commander V6.46h (Compiled Jun 28 2019 17:19:57)
DLL version V6.46h, compiled Jun 28 2019 17:19:50
Connecting to J-Link via USB…O.K.
Firmware: J-Link ARM V8 compiled Nov 28 2014 13:44:46
Hardware version: V8.00
S/N: 26800XXXX
License(s): FlashBP, GDB
OEM: SEGGER-EDU

VTref=3.306V
Type "connect" to establish a target connection, '?' for help
J-Link>connect
Specify target interface speed [kHz]. : 4000 kHz
Speed>4000

Device "ATSAML21G18" selected.
Connecting to target via SWD
InitTarget()
Found SW-DP with ID 0x0BC11477

Scanning AP map to find all available APs
AP[1]: Stopped AP scan as end of AP map has been reached
AP[0]: AHB-AP (IDR: 0x04770031)
Iterating through AP map to find AHB-AP to use
AP[0]: Core found
AP[0]: AHB-AP ROM base: 0x41003000
CPUID register: 0x410CC601. Implementer code: 0x41 (ARM)
Found Cortex-M0 r0p1, Little endian.
FPUnit: 4 code (BP) slots and 0 literal slots
CoreSight components:
ROMTbl[0] @ 41003000
ROMTbl[0][0]: E00FF000, CID: B105100D, PID: 000BB4C0 ROM Table
ROMTbl[1] @ E00FF000
ROMTbl[1][0]: E000E000, CID: B105E00D, PID: 000BB008 SCS
ROMTbl[1][1]: E0001000, CID: B105E00D, PID: 000BB00A DWT
ROMTbl[1][2]: E0002000, CID: B105E00D, PID: 000BB00B FPB
ROMTbl[0][1]: 41006000, CID: B105900D, PID: 001BB932 MTB-M0+
Cortex-M0 identified.
J-Link>loadbin nuttx.bin 0

Now use a USB/Serial and connect the RXD to RXD pad of the board and TXD to TXD pad. Configure the minicom to use 115200 8n1 and after reseting the board you should get:

NuttShell (NSH)
nsh>

Using DS1307 RTC Module with NuttX

Kids, always read the datasheet before starting wiring your module. I always said it to other people, but sometimes I’m anxious to get things working and fail to follow my own advice.

It happened again with DS1307 Module that I got from Aliexpress:

I connected it to STM32F4Discovery board this way:

----------------------------------
STM32F4Discovery |  DS1307 Module
-----------------+----------------
GND              |   GND
3V               |   VCC
SDA              |   PB9
SCL              |   PB7
-----------------+----------------

But when NuttX was starting it was failing to communicate with the module, returning error -6 (= ENXIO = “No such device or address”) :

ABCDF
 stm32_ds1307_init: Initialize I2C1
 stm32_ds1307_init: Bind the DS1307 RTC driver to I2C1
 up_rtc_getdatetime: ERROR: I2C_TRANSFER failed: -6

I used the Logic Analyzer and saw that the address was sent correctly, but the board wasn’t responding. After some time I decided to look the datasheet to confirm that it could work with 3V (I assumed it because the module uses a 3V battery) and to my surprise it only works from 4.5V to 5V.

Then connecting the VCC from the module to 5V worked:

ABCDF
stm32_ds1307_init: Initialize I2C1
stm32_ds1307_init: Bind the DS1307 RTC driver to I2C1
rtc_dumptime: Returning:
rtc_dumptime: tm_sec: 00000026
rtc_dumptime: tm_min: 00000024
rtc_dumptime: tm_hour: 00000004
rtc_dumptime: tm_mday: 00000019
rtc_dumptime: tm_mon: 00000009
rtc_dumptime: tm_year: 00000068
nsh> date
Oct 25 04:36:56 2004

nsh> date -s "Sep 22 08:04:00 2019"
up_rtc_settime: Setting time tp=(1569139440,0)
rtc_dumptime: New time:
rtc_dumptime: tm_sec: 00000000
rtc_dumptime: tm_min: 00000004
rtc_dumptime: tm_hour: 00000008
rtc_dumptime: tm_mday: 00000016
rtc_dumptime: tm_mon: 00000008
rtc_dumptime: tm_year: 00000077
nsh>

I turned the board OFF and let it alone some minutes and when I connected it again the time was correct:

NuttShell (NSH)
nsh> date
Sep 22 08:23:41 2019
nsh>

These are the main options I enabled on NuttX to get it working:

 STM32_I2C1
 STM32_I2C
 RTC
 RTC_DATETIME
 RTC_DS1307
 RTC_DSXXXX
 RTC_EXTERNAL

After installing Ubuntu 9.04 setup your terminal

After Ubuntu installation a real developer needs to setup the terminal:

Terminal -> Preferences

Click on “Unnamed” profile and select:

Custom font: Ubuntu Mono Regular size 15

Click on “Colors” tab, disable the “Use colors from system theme” and select:

“Green on black”

Click on “Scrolling” tab disable “Limit scrollback to:”

Close and you are done.

If you want other good font to use on Linux terminal:

$ sudo apt-get install fonts-inconsolata

I got the Inconsolata font suggestion from this site (its fonts packages are outdated) http://www.webupd8.org/2010/07/7-of-best-ubuntu-terminal-fixed-width.html