Month: November 2015

JLinkExe bad behaviour

It is strange, JLinkExe fails to flash a new STM32F407 board that I just mounted:

$ sudo JLinkExe -if SWD
SEGGER J-Link Commander V4.98e ('?' for help)
Compiled May  5 2015 11:49:39
DLL version V4.98e, compiled May  5 2015 11:49:35
Firmware: J-Link ARM V8 compiled Nov 28 2014 13:44:46
Hardware: V8.00
S/N: 268006167 
OEM: SEGGER-EDU 
Feature(s): FlashBP, GDB 
VTarget = 3.300V
Info: Found SWD-DP with ID 0x2BA01477
Info: Found Cortex-M4 r0p1, Little endian.
Info: FPUnit: 6 code (BP) slots and 2 literal slots
Info: CoreSight components:
Info: ROMTbl 0 @ E00FF000
Info: ROMTbl 0 [0]: FFF0F000, CID: B105E00D, PID: 000BB00C SCS
Info: ROMTbl 0 [1]: FFF02000, CID: B105E00D, PID: 003BB002 DWT
Info: ROMTbl 0 [2]: FFF03000, CID: B105E00D, PID: 002BB003 FPB
Info: ROMTbl 0 [3]: FFF01000, CID: B105E00D, PID: 003BB001 ITM
Info: ROMTbl 0 [4]: FFF41000, CID: B105900D, PID: 000BB9A1 TPIU
Info: ROMTbl 0 [5]: FFF42000, CID: B105900D, PID: 000BB925 ETM
Cortex-M4 identified.
Target interface speed: 100 kHz

J-Link>device stm32f407ve
Info: Device "STM32F407VE" selected.
Reconnecting to target...
Info: Found SWD-DP with ID 0x2BA01477
Info: Found SWD-DP with ID 0x2BA01477
Info: Found Cortex-M4 r0p1, Little endian.
Info: FPUnit: 6 code (BP) slots and 2 literal slots
Info: CoreSight components:
Info: ROMTbl 0 @ E00FF000
Info: ROMTbl 0 [0]: FFF0F000, CID: B105E00D, PID: 000BB00C SCS
Info: ROMTbl 0 [1]: FFF02000, CID: B105E00D, PID: 003BB002 DWT
Info: ROMTbl 0 [2]: FFF03000, CID: B105E00D, PID: 002BB003 FPB
Info: ROMTbl 0 [3]: FFF01000, CID: B105E00D, PID: 003BB001 ITM
Info: ROMTbl 0 [4]: FFF41000, CID: B105900D, PID: 000BB9A1 TPIU
Info: ROMTbl 0 [5]: FFF42000, CID: B105900D, PID: 000BB925 ETM

J-Link>loadbin ./nuttx.bin 0
Halting CPU for downloading file.
Downloading file [./nuttx.bin]...Writing target memory failed.

Using this command it works:

J-Link>exec device stm32f407ve
Info: Device "STM32F407VE" selected.
J-Link>loadbin ./nuttx.bin 0
Info: TotalIRLen = 9, IRPrint = 0x0011
Info: TotalIRLen = 9, IRPrint = 0x0011
Info: Found Cortex-M4 r0p1, Little endian.
Info: FPUnit: 6 code (BP) slots and 2 literal slots
Info: CoreSight components:
Info: ROMTbl 0 @ E00FF000
Info: ROMTbl 0 [0]: FFF0F000, CID: B105E00D, PID: 000BB00C SCS
Info: ROMTbl 0 [1]: FFF02000, CID: B105E00D, PID: 003BB002 DWT
Info: ROMTbl 0 [2]: FFF03000, CID: B105E00D, PID: 002BB003 FPB
Info: ROMTbl 0 [3]: FFF01000, CID: B105E00D, PID: 003BB001 ITM
Info: ROMTbl 0 [4]: FFF41000, CID: B105900D, PID: 000BB9A1 TPIU
Info: ROMTbl 0 [5]: FFF42000, CID: B105900D, PID: 000BB925 ETM
Halting CPU for downloading file.
Downloading file [./nuttx.bin]...O.K.

I suspect there is something wrong in my board because the above command work fine in the boards that I mounted few weeks ago.

Using SmartFS on NuttX

After fixing many issues and thanks to help of Greg Nutt and Ken Petit (SmartFS author) finally I got SmartFS working on NuttX.

This is the NuttX initialization with FileSystem debug enabled:

ABCDF
smart_scan: SMART Scan
smart_scan:    Erase size:          512
smart_scan:    Erase count:        5120
smart_scan:    Sect/block:            1
smart_scan:    MTD Blk/Sect:          1
smart_scan: SMART Scan
smart_scan:    Erase size:          512
smart_scan:    Erase count:        5120
smart_scan:    Sect/block:            1
smart_scan:    MTD Blk/Sect:          1
smart_scan: SMART Scan
smart_scan:    Erase size:          512
smart_scan:    Erase count:        2048
smart_scan:    Sect/block:            1
smart_scan:    MTD Blk/Sect:          1
smart_scan: SMART Scan
smart_scan:    Erase size:          512
smart_scan:    Erase count:        2048
smart_scan:    Sect/block:            1
smart_scan:    MTD Blk/Sect:          1
smart_scan: SMART Scan
smart_scan:    Erase size:          512
smart_scan:    Erase count:        1016
smart_scan:    Sect/block:            1
smart_scan:    MTD Blk/Sect:          1
smart_scan: SMART Scan
smart_scan:    Erase size:          512
smart_scan:    Erase count:        1016
smart_scan:    Sect/block:            1
smart_scan:    MTD Blk/Sect:          1

NuttShell (NSH)
nsh>

Now let see the enabled commands:

nsh> ?
help usage:  help [-v] []

[           dd          hexdump     mkdir       ping        test
?           df          ifconfig    mkfifo      ps          true
break       echo        ifdown      mkrd        pwd         uname
cat         exec        ifup        mksmartfs   rm          umount
cd          exit        kill        mh          rmdir       unset
cp          false       losetup     mount       set         usleep
cmp         free        ls          mv          sh          xd
date        help        mb          mw          sleep

Builtin Apps:
flash_eraseall
pppd
tracker
nsh>

And the created devices:

nsh> ls /dev
/dev:
config
console
null
smart0p1
smart0p2
smart0p3
smart0p4
smart0p5
smart0p6
ttyS0
ttyS1
ttyS2
ttyS3
ttyS4
ttyS5
tun
nsh>

Time to format the smartfs partitions:

nsh> flash_eraseall /dev/smart0p1

Create the file system on it:

nsh> mksmartfs /dev/smart0p1
smart_scan: SMART Scan
smart_scan:    Erase size:          512
smart_scan:    Erase count:        5120
smart_scan:    Sect/block:            1
smart_scan:    MTD Blk/Sect:          1

nsh> mksmartfs /dev/smart0p2
smart_scan: SMART Scan
smart_scan:    Erase size:          512
smart_scan:    Erase count:        5120
smart_scan:    Sect/block:            1
smart_scan:    MTD Blk/Sect:          1

nsh> mksmartfs /dev/smart0p3
smart_scan: SMART Scan
smart_scan:    Erase size:          512
smart_scan:    Erase count:        2048
smart_scan:    Sect/block:            1
smart_scan:    MTD Blk/Sect:          1

nsh> mksmartfs /dev/smart0p4
smart_scan: SMART Scan
smart_scan:    Erase size:          512
smart_scan:    Erase count:        2048
smart_scan:    Sect/block:            1
smart_scan:    MTD Blk/Sect:          1

nsh> mksmartfs /dev/smart0p5
smart_scan: SMART Scan
smart_scan:    Erase size:          512
smart_scan:    Erase count:        1016
smart_scan:    Sect/block:            1
smart_scan:    MTD Blk/Sect:          1

nsh> mksmartfs /dev/smart0p6
smart_scan: SMART Scan
smart_scan:    Erase size:          512
smart_scan:    Erase count:        1016
smart_scan:    Sect/block:            1
smart_scan:    MTD Blk/Sect:          1
nsh>

Finally let to mount it:

nsh> mount -t smartfs /dev/smart0p1 /mnt/
smartfs_mount: SMARTFS:
smartfs_mount:      Sector size:     512
smartfs_mount:      Bytes/sector     507
smartfs_mount:      Num sectors:     5120
smartfs_mount:      Free sectors:    5113
smartfs_mount:      Max filename:    16
smartfs_mount:      RootDirSector:   3
nsh>

Your redemption is drawing near:

nsh> mkdir /mnt/teste

nsh> ls /mnt/
/mnt/:
 teste/

nsh> cd /mnt
nsh> ls -l
/mnt:
 drwxrwxrwx       0 teste/

nsh> df
  Block  Number
  Size   Blocks     Used Available Mounted on
   512     5120        8      5112 /mnt
nsh> 

Does anyone doubt that NuttX rocks?!?

Just for your information this is my configuration:

CONFIG_MTD=y
CONFIG_MTD_PARTITION=y
CONFIG_MTD_SECT512=y
CONFIG_MTD_SECT512_ERASED_STATE=0xff
CONFIG_MTD_PARTITION_NAMES=y
CONFIG_MTD_BYTE_WRITE=y
CONFIG_MTD_CONFIG=y
CONFIG_MTD_CONFIG_RAM_CONSOLIDATE=y
CONFIG_MTD_CONFIG_ERASEDVALUE=0xff
# MTD Device Drivers
# CONFIG_MTD_NAND is not set

CONFIG_RAMMTD=y
CONFIG_RAMMTD_BLOCKSIZE=512
CONFIG_RAMMTD_ERASESIZE=4096
CONFIG_RAMMTD_ERASESTATE=0xff

CONFIG_MTD_SMART=y
CONFIG_MTD_SMART_SECTOR_SIZE=512
# CONFIG_MTD_SMART_WEAR_LEVEL is not set
# CONFIG_MTD_SMART_CONVERT_WEAR_FORMAT is not set
# CONFIG_MTD_SMART_ENABLE_CRC is not set
# CONFIG_MTD_SMART_MINIMIZE_RAM is not set
# CONFIG_MTD_SMART_SECTOR_ERASE_DEBUG is not set
# CONFIG_MTD_SMART_ALLOC_DEBUG is not set

CONFIG_MTD_W25=y


CONFIG_FS_SMARTFS=y
CONFIG_SMARTFS_ERASEDSTATE=0xff
CONFIG_SMARTFS_MAXNAMLEN=16
# CONFIG_SMARTFS_MULTI_ROOT_DIRS is not set
# CONFIG_SMARTFS_ALIGNED_ACCESS is not set

And this gist with the SmartFS partition initialization:


/****************************************************************************
* config/shenzhou/src/stm32_w25.c
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/mount.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <debug.h>
#ifdef CONFIG_STM32_SPI1
# include <nuttx/spi/spi.h>
# include <nuttx/mtd/mtd.h>
# include <nuttx/fs/smart.h>
# include <nuttx/configdata.h>
#endif
#include "stm32_spi.h"
#include "htptracker.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#if defined(CONFIG_DEBUG)
#define w25info dbg
#else
#if defined(CONFIG_DEBUG_INFO)
#define w25info _info
#else
#define w25info(x…)
#endif
#endif
/* Debug ***************************************************************************/
/* Non-standard debug that may be enabled just for testing the watchdog timer */
#define W25_SPI_PORT 1
/* Configuration ************************************************************/
/* Can't support the W25 device if it SPI1 or W25 support is not enabled */
#define HAVE_W25 1
#if !defined(CONFIG_STM32_SPI1) || !defined(CONFIG_MTD_W25)
# undef HAVE_W25
#endif
/* Can't support W25 features if mountpoints are disabled */
#if defined(CONFIG_DISABLE_MOUNTPOINT)
# undef HAVE_W25
#endif
/* Can't support both FAT and SMARTFS */
#if defined(CONFIG_FS_FAT) && defined(CONFIG_FS_SMARTFS)
# warning "Can't support both FAT and SMARTFS — using FAT"
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: stm32_w25initialize
*
* Description:
* Initialize and register the W25 FLASH file system.
*
****************************************************************************/
int stm32_w25initialize(int minor)
{
int ret;
#ifdef HAVE_W25
FAR struct spi_dev_s *spi;
FAR struct mtd_dev_s *mtd;
FAR struct mtd_geometry_s geo;
#if defined(CONFIG_MTD_PARTITION_NAMES)
FAR const char *partname = CONFIG_HTPTRACKER_FLASH_PART_NAMES;
#endif
/* Get the SPI port */
spi = stm32_spibus_initialize(W25_SPI_PORT);
if (!spi)
{
w25info("ERROR: Failed to initialize SPI port %d\n", W25_SPI_PORT);
return -ENODEV;
}
/* Now bind the SPI interface to the W25 SPI FLASH driver */
mtd = w25_initialize(spi);
if (!mtd)
{
w25info("ERROR: Failed to bind SPI port %d to the SST 25 FLASH driver\n", W25_SPI_PORT);
return -ENODEV;
}
#ifndef CONFIG_FS_SMARTFS
/* And finally, use the FTL layer to wrap the MTD driver as a block driver */
ret = ftl_initialize(minor, mtd);
if (ret < 0)
{
w25info("ERROR: Initialize the FTL layer\n");
return ret;
}
#else
/* Initialize to provide SMARTFS on the MTD interface */
/* Get the geometry of the FLASH device */
ret = mtd->ioctl(mtd, MTDIOC_GEOMETRY, (unsigned long)((uintptr_t)&geo));
if (ret < 0)
{
w25info("ERROR: mtd->ioctl failed: %d\n", ret);
return ret;
}
#ifdef CONFIG_HTPTRACKER_FLASH_PART
{
int partno;
int partsize;
int partoffset;
int partszbytes;
int erasesize;
const char *partstring = CONFIG_HTPTRACKER_FLASH_PART_LIST;
const char *ptr;
FAR struct mtd_dev_s *mtd_part;
char partref[4];
/* Now create a partition on the FLASH device */
partno = 0;
ptr = partstring;
partoffset = 0;
/* Get the Flash erase size */
erasesize = geo.erasesize;
while (*ptr != '\0')
{
/* Get the partition size */
partsize = atoi(ptr);
partszbytes = (partsize << 10); /* partsize is defined in KB */
/* Check if partition size is bigger then erase block */
if (partszbytes < erasesize)
{
w25info("ERROR: Partition size is lesser than erasesize!\n");
return1;
}
/* Check if partition size is multiple of erase block */
if ( (partszbytes % erasesize) !=0 )
{
w25info("ERROR: Partition size is not multiple of erasesize!\n");
return1;
}
mtd_part = mtd_partition(mtd, partoffset, partszbytes/ erasesize);
partoffset += partszbytes / erasesize;
#ifdef CONFIG_HTPTRACKER_FLASH_CONFIG_PART
/* Test if this is the config partition */
if (CONFIG_HTPTRACKER_FLASH_CONFIG_PART_NUMBER == partno)
{
/* Register the partition as the config device */
mtdconfig_register(mtd_part);
}
else
#endif
{
/* Now initialize a SMART Flash block device and bind it
* to the MTD device.
*/
#if defined(CONFIG_MTD_SMART) && defined(CONFIG_FS_SMARTFS)
sprintf(partref, "p%d", partno);
smart_initialize(CONFIG_HTPTRACKER_FLASH_MINOR, mtd_part, partref);
#endif
}
/* Set the partition name */
#if defined(CONFIG_MTD_PARTITION_NAMES)
if (!mtd_part)
{
w25info("Error: failed to create partition %s\n", partname);
return1;
}
mtd_setpartitionname(mtd_part, partname);
/* Now skip to next name. We don't need to split the string here
* because the MTD partition logic will only display names up to
* the comma, thus allowing us to use a single static name
* in the code.
*/
while (*partname != ',' && *partname != '\0')
{
/* Skip to next ',' */
partname++;
}
if (*partname == ',')
{
partname++;
}
#endif
/* Update the pointer to point to the next size in the list */
while ((*ptr >= '0') && (*ptr <= '9'))
{
ptr++;
}
if (*ptr == ',')
{
ptr++;
}
/* Increment the part number */
partno++;
}
}
#else /* CONFIG_HTPTRACKER_FLASH_PART */
/* Configure the device with no partition support */
smart_initialize(CONFIG_HTPTRACKER_FLASH_MINOR, mtd, NULL);
#endif /* CONFIG_HTPTRACKER_FLASH_PART */
#endif /* CONFIG_FS_SMARTFS */
#endif /* HAVE_W25 */
/* Create a RAM MTD device if configured */
#if defined(CONFIG_RAMMTD) && defined(CONFIG_HTPTRACKER_RAMMTD)
{
uint8_t *start = (uint8_t *) kmm_malloc(CONFIG_HTPTRACKER_RAMMTD_SIZE * 1024);
mtd = rammtd_initialize(start, CONFIG_HTPTRACKER_RAMMTD_SIZE * 1024);
mtd->ioctl(mtd, MTDIOC_BULKERASE, 0);
/* Now initialize a SMART Flash block device and bind it to the MTD device */
#if defined(CONFIG_MTD_SMART) && defined(CONFIG_FS_SMARTFS)
smart_initialize(CONFIG_HTPTRACKER_RAMMTD_MINOR, mtd, NULL);
#endif
}
#endif /* CONFIG_RAMMTD && CONFIG_HTPTRACKER_RAMMTD */
return OK;
}

view raw

stm32_w25.c

hosted with ❤ by GitHub

Using the Linux screen command as terminal emulator to serial console

I want to read the output of NuttX’s hexdump to see if a binary file was generated correctly. Unfortunately using “minicom” to select and read text it not an option.

Then I decided to use Linux “screen” command to see the serial console of my board running NuttX.

First install screen:

$ sudo apt-get install screen

Now you need to execute the “script” command to copy everything from your Linux console:

$ script
Script started, file is typescript

Then just run screen:

$ screen /dev/ttyUSB0 115200

In the NuttX prompt execute the hexdump command:

nsh> ls -l
/mnt:
 -rw-rw-rw-      13 TESTE.TXT
 -rw-rw-rw-   36160 TRKLOG.DB
 -rw-rw-rw-     640 HEADER.TXT
nsh> hexdump /mnt/TRKLOG.DB
...
01f0: 58 5e 3d c2 ec 96 82 94 ff a0 9c 8c b1 5a 04 6c X^=..........Z.l
/mnt/TRKLOG.DB at 00008c00:
0000: 13 82 ee 1e 8c 80 47 56 00 00 00 00 00 00 00 00 ......GV........
0010: 00 00 00 00 00 00 00 00 00 00 00 00 e0 2e 74 0e ..............t.
...

To exit from “screen” press the sequence: Ctrl + a + k
It will show>

Really kill this window [y/n] y
[screen is terminating]

Now leave the “script” command:

$ exit
exit
Script done, file is typescript

If you open typescript you will see the complete dump:

$ vi typescript

Script started on Sat 14 Nov 2015 05:23:08 PM BRST
$ screen /dev/ttyUSB0 115200^M
^[[r^[[m^[[2J^[[H^[[?7h^[[?1;4;6l^[[?1049h^[[4l^[[?1h^[=^[[0m^[(B^[[1;27r^[[H^[[2J^[[H^[[2J
nsh> ^[[Kls -l^M
/mnt:^M
 -rw-rw-rw-      13 TESTE.TXT^M
 -rw-rw-rw-   36160 TRKLOG.DB^M
 -rw-rw-rw-     640 HEADER.TXT^M
nsh> ^[[Khexdump TRKLOG.DB^M
nsh: hexdump: open failed: 2^M
nsh> ^[[Khexdump TRKLOG.DB^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[Khexdump TRKLOG.DB^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[Khexdump TRKLOG.DB^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[Khexdump TRKLOG.DB^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K/mnt/TRKLOG.DB^M
/mnt/TRKLOG.DB at 00000000:^M
0000: 13 82 ee 1e 33 06 93 b9 00 00 00 00 00 00 00 00 ....3...........^M
0010: 00 00 00 00 00 00 00 00 00 00 00 00 e0 2e 74 0e ..............t.^M
0020: cc 79 7e 45 25 9a 7b cb 2b 6e aa 00 00 00 00 aa .y~E%.{.+n......^M
0030: 58 5e 3d c2 ec 96 82 94 ff a0 9c 8c b1 5a 04 6c X^=..........Z.l^M

Nice, but we need to remove the header (use the editor to remove o header) and these lines starting with /mnt/TRKLOG.DB :

$ sed -i '/^\/mnt/d' typescript

Good, now we need to remove the first 6 characters at beginning of each line:

$ sed -i 's/^.\{,6\}//' typescript

Also the last 17 characters at end of line:

$ sed -i 's/.\{,17\}$//' typescript

Finally we have only the useful information:

13 82 ee 1e 8f 80 47 56 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 e0 2e 74 0e 
cc 79 7e 45 25 9a 7b cb 2b 6e aa 00 00 00 00 aa 
58 5e 3d c2 ec 96 82 94 ff a0 9c 8c b1 5a 04 6c 
13 82 ee 1e 90 80 47 56 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 e0 2e 74 0e 
cc 79 7e 45 25 9a 7b cb 2b 6e aa 00 00 00 00 aa 
58 5e 3d c2 ec 96 82 94 ff a0 9c 8c b1 5a 04 6c

Pintura com tinta de poliuretano e tipos de catalizadores

Resolvi pintar algumas partes do CNC que estou montando com tinta poliuretano.

Pintar com tinta à base de poliuretano tem a vantagem de um acabamento muito profissional, mas exige um certo cuidado.

Após fazer várias pesquisas na internet, descobrir os tipos de primers eu teria que usar, etc, então resolvi comprar o primer e a tinta.

O primeiro problema é que não foi muito fácil encontrar este tipo de tinta aqui em BH. Assim, tive que comprar a marca que havia disponível na loja de tintas no centro da cidade.

E embora em todos os sites e fóruns se recomenda sempre usar primers e tintas da mesma marca para evitar problemas, o dono da loja de tinta automotiva disse que não tinha o Wash Primer Fundo Fosfatizante da mesma marca da tinta que eu estava comprando, mas que ele trabalha com isso há mais de 10 anos e nenhum cliente teve problemas.

Então acabei comprando o wash primer da Maza:

Maza Wash Primer Fundo Fostatizante (468.05277)

Comprei as tintas da marcar Stardur (grupo WEG, isso mesmo, aquela empresa que fabrica motores elétricos), seguem abaixo os detalhes:

Starmix Primer S10 (12254049)
Starcar Poliuretano Vermelho FlashII VW00 (12659086)
Stardur Endurecedor 5502 (12725002)
Stardur Endurecedor 5508 (12672442)

A confusão começou quando cheguei em casa, qual Endurecedor vai em qual Tinta/Primer?

Procurei na Internet, procurei no site da empresa, mas nada, finalmente decidi ligar p/ a empresa e eles esclareceram o enigma:

Para a Starmix Primer S10 eu tenho que usar o Stardur Endurecedor 5508.
Para a Starmix Poliuretano Verm. FlashII devo usar o Stardur Endurecedor 5502.

A proporção é a seguinte:

Tinta Maza / Endurecedor = 2 : 1
Primer Stardur S10 / Endurecedor 5508 = 5:1 diluir 30%
Tinta Starcar Verm / Endurecedor 5502 = 3:1 diluir 10-20%

Pronto, depois vou postar o vídeo mostrando o processo de pintura e o resultado final.

Keep your git repository updated with a friend’s repository

This is the way I use to keep my repository in sync when working on a project together with a friend:

Clone your main project:

$ git clone git.yourproject.com/projectname.get

Add your friend repository:

$ git remote add yourfriend git.yourfriend.com/hisprojectname.git

Create a new branch to receive your friend modifications:

$ git branch develop
$ git checkout develop

Pull the commits from your friend repository:

$ git pull yourfriend master

Return to you master branch and merge modifications:

$ git checkout master
$ git merge develop

Send modifications to your repository:

$ git push origin master

Other alternative:

$ git remote add yourfriend git.yourfriend.com/hisprojectname.git

$ git fetch yourfriend

$ git rebase yourfriend/master

$ git push origin master

Testing U-Blox Sara-G350 on NuttX

This is the result of my Sara G350 debug on NuttX:

NuttShell (NSH)
nsh> pppd
tun fd:3
tty fd:4
ipcp init

AHDLC_TX - transmit frame, protocol 0xc021, length 4  offline 0

0x05 0x01 0x00 0x04 


AHDLC_TX - transmit frame, protocol 0xc021, length 4  offline 1

0x05 0x02 0x00 0x04 

chat: char = ~ (0x7E)
chat: char = � (0xFF)
chat: char = } (0x7D)
chat: char = # (0x23)
chat: char = � (0xC2)
chat: char = # (0x23)
chat: char = (0x7F)
chat: char = ' (0x27)
chat: char = (0x7F)
chat: char = # (0x23)
chat: char = (0x7F)
chat: char = " (0x22)
chat: char = (0x7F)
chat: char = & (0x26)
chat: char = ? (0x3F)
chat: char = � (0xC7)
chat: char = ~ (0x7E)
chat: char = ~ (0x7E)
chat: char = � (0xFF)
chat: char = } (0x7D)
chat: char = # (0x23)
chat: char = � (0xC1)
chat: char = ! (0x21)
chat: char = } (0x7D)
chat: char = % (0x25)
chat: char = } (0x7D)
chat: char = " (0x22)
chat: char = } (0x7D)
chat: char =   (0x20)
chat: char = } (0x7D)
chat: char = % (0x25)
chat: char = Y (0x59)
chat: char = ) (0x29)
chat: char = ~ (0x7E)
chat: char = + (0x2B)
chat: char = ; (0x3B)
chat: char = + (0x2B)
chat: char = A (0x41)
chat: char = T (0x54)
chat: char = E (0x45)
chat: char = 1 (0x31)
 (0x0D)har = 
 (0x0D)har = 
chat: char = 
 (0x0A)
chat: char = O (0x4F)
chat: char = K (0x4B)
 (0x0D)har = 
chat: char = 
 (0x0A)
chat: send 'ATZ`
chat_check_response read: 
chat: char = A (0x41)
chat_check_response read: A
chat: char = T (0x54)
chat_check_response read: T
chat: char = Z (0x5A)
chat: wait for 'OK`
chat_check_response read: 
 (0x0D)har = 
chat_check_response read: 
 (0x0D)har = 
chat_check_response read: 
chat: char = 
 (0x0A)
chat_check_response read: 

chat: char = O (0x4F)
chat_check_response read: O
chat: char = K (0x4B)
chat: got it!
 (0x0D)har = 
chat: char = 
 (0x0A)
chat: send 'AT`
chat_check_response read: 
chat: char = A (0x41)
chat_check_response read: A
chat: char = T (0x54)
chat: wait for 'OK`
chat_check_response read: 
 (0x0D)har = 
chat_check_response read: 
 (0x0D)har = 
chat_check_response read: 
chat: char = 
 (0x0A)
chat_check_response read: 

chat: char = O (0x4F)
chat_check_response read: O
chat: char = K (0x4B)
chat: got it!
 (0x0D)har = 
chat: char = 
 (0x0A)
chat: send 'AT+CGDCONT = 1,"IP","internet"`
chat_check_response read: 
chat: char = A (0x41)
chat_check_response read: A
chat: char = T (0x54)
chat_check_response read: T
chat: char = + (0x2B)
chat_check_response read: +
chat: char = C (0x43)
chat_check_response read: C
chat: char = G (0x47)
chat_check_response read: G
chat: char = D (0x44)
chat_check_response read: D
chat: char = C (0x43)
chat_check_response read: C
chat: char = O (0x4F)
chat_check_response read: O
chat: char = N (0x4E)
chat_check_response read: N
chat: char = T (0x54)
chat_check_response read: T
chat: char =   (0x20)
chat_check_response read:  
chat: char = = (0x3D)
chat_check_response read: =
chat: char =   (0x20)
chat_check_response read:  
chat: char = 1 (0x31)
chat_check_response read: 1
chat: char = , (0x2C)
chat_check_response read: ,
chat: char = " (0x22)
chat_check_response read: "
chat: char = I (0x49)
chat_check_response read: I
chat: char = P (0x50)
chat_check_response read: P
chat: char = " (0x22)
chat_check_response read: "
chat: char = , (0x2C)
chat_check_response read: ,
chat: char = " (0x22)
chat_check_response read: "
chat: char = i (0x69)
chat_check_response read: i
chat: char = n (0x6E)
chat_check_response read: n
chat: char = t (0x74)
chat_check_response read: t
chat: char = e (0x65)
chat_check_response read: e
chat: char = r (0x72)
chat_check_response read: r
chat: char = n (0x6E)
chat_check_response read: n
chat: char = e (0x65)
chat_check_response read: e
chat: char = t (0x74)
chat_check_response read: t
chat: char = " (0x22)
chat: wait for 'OK`
chat_check_response read: 
 (0x0D)har = 
chat_check_response read: 
 (0x0D)har = 
chat_check_response read: 
chat: char = 
 (0x0A)
chat_check_response read: 

chat: char = O (0x4F)
chat_check_response read: O
chat: char = K (0x4B)
chat: got it!
 (0x0D)har = 
chat: char = 
 (0x0A)
chat: send 'ATD*99***1#`
chat_check_response read: 
chat: char = A (0x41)
chat_check_response read: A
chat: char = T (0x54)
chat_check_response read: T
chat: char = D (0x44)
chat_check_response read: D
chat: char = * (0x2A)
chat_check_response read: *
chat: char = 9 (0x39)
chat_check_response read: 9
chat: char = 9 (0x39)
chat_check_response read: 9
chat: char = * (0x2A)
chat_check_response read: *
chat: char = * (0x2A)
chat_check_response read: *
chat: char = * (0x2A)
chat_check_response read: *
chat: char = 1 (0x31)
chat_check_response read: 1
chat: char = # (0x23)
chat: wait for 'CONNECT`
chat_check_response read: 
 (0x0D)har = 
chat_check_response read: 
 (0x0D)har = 
chat_check_response read: 
chat: char = 
 (0x0A)
chat_check_response read: 

chat: char = C (0x43)
chat_check_response read: C
chat: char = O (0x4F)
chat_check_response read: O
chat: char = N (0x4E)
chat_check_response read: N
chat: char = N (0x4E)
chat_check_response read: N
chat: char = E (0x45)
chat_check_response read: E
chat: char = C (0x43)
chat_check_response read: C
chat: char = T (0x54)
chat: got it!
ipcp init
ipcp init

Sending LCP request packet -  len 10

AHDLC_TX - transmit frame, protocol 0xc021, length 10  offline 0

0x01 0x00 0x00 0x0a 0x02 0x06 0xff 0xff 0xff 0xff 


Receiving packet with good crc value, len 24

0x01 0x01 0x00 0x14 0x02 0x06 0x00 0x00 0x00 0x00 0x05 0x06 0xed 0xb6 0x5b 0x05 
0x07 0x02 0x08 0x02 

LCP Packet - ipcp init
received [LCP Config Request id 1
   
Send ACK!
Writing ACK frame 

AHDLC_TX - transmit frame, protocol 0xc021, length 20  offline 1

0x02 0x01 0x00 0x14 0x02 0x06 0x00 0x00 0x00 0x00 0x05 0x06 0xed 0xb6 0x5b 0x05 0x07 0x02 0x08 0x02 

- end ACK Write frame


Receiving packet with good crc value, len 14

0x02 0x00 0x00 0x0a 0x02 0x06 0xff 0xff 0xff 0xff 

LCP Packet - LCP-ACK - >>>>>>>> good ACK id up! 0


**Sending IPCP Request packet

AHDLC_TX - transmit frame, protocol 0x8021, length 10  offline 0

0x01 0x00 0x00 0x0a 0x03 0x06 0x00 0x00 0x00 0x00 


Receiving packet with good crc value, len 14

0x01 0x01 0x00 0x0a 0x03 0x06 0xbf 0x78 0xee 0x5e 

IPCP Packet - IPCP len 10
check lcplist
IPCP options are good
Peer IP 
Send IPCP ACK!
SET- stuff -- are we up? c=10 dif=2 
Writing ACK frame 

AHDLC_TX - transmit frame, protocol 0x8021, length 10  offline 1

0x02 0x01 0x00 0x0a 0x03 0x06 0xbf 0x78 0xee 0x5e 

- End ACK Write frame


Receiving packet with good crc value, len 14

0x03 0x00 0x00 0x0a 0x03 0x06 0xbf 0x78 0xee 0x5e 

IPCP Packet - IPCP len 10
CONF NAK



**Sending IPCP Request packet

AHDLC_TX - transmit frame, protocol 0x8021, length 10  offline 0

0x01 0x01 0x00 0x0a 0x03 0x06 0xbf 0x78 0xee 0x5e 


Receiving packet with good crc value, len 14

0x02 0x01 0x00 0x0a 0x03 0x06 0xbf 0x78 0xee 0x5e 

IPCP Packet - IPCP len 10
CONF ACK
were up! 



Receiving packet with good crc value, len 44

0x45 0x00 0x00 0x28 0x7b 0xfb 0x40 0x00 0x40 0x06 0xfc 0xf0 0xad 0xfc 0x66 0x10 
0xbf 0x78 0xee 0x5e 0x01 0xbb 0xd6 0x15 0x39 0x78 0xcc 0xf2 0x00 0x00 0x00 0x00 0x50 0x04 0x00 0x00 0x0f 0xc1 0x00 0x00 

IPV4 Packet---

 len 8

Writing ECHO-REQUEST frame 

AHDLC_TX - transmit frame, protocol 0xc021, length 8  offline 0

0x09 0x01 0x00 0x08 0x00 0x00 0x00 0x00 

- end ECHO-REQUEST Write frame

Receiving packet with good crc value, len 12

0x0a 0x01 0x00 0x08 0xed 0xb6 0x5b 0x05 

LCP Packet - LCP-ECHO REPLY


Receiving packet with good crc value, len 44

0x45 0x00 0x00 0x28 0x0a 0x36 0x40 0x00 0x40 0x06 0xfd 0x24 0x41 0x37 0x44 0x67 
0xbf 0x78 0xee 0x5e 0x01 0xbb 0xa7 0x8c 0x87 0x92 0x83 0x53 0x00 0x00 0x00 0x00 0x50 0x04 0x00 0x00 0xc8 0x3d 0x00 0x00 

IPV4 Packet---


Receiving packet with good crc value, len 44

0x45 0x00 0x00 0x28 0x92 0xf2 0x40 0x00 0x40 0x06 0xe5 0xf9 0xad 0xfc 0x66 0x10 
0xbf 0x78 0xee 0x5e 0x01 0xbb 0xcf 0xf6 0x06 0x37 0xf1 0xec 0x00 0x00 0x00 0x00 0x50 0x04 0x00 0x00 0x24 0x27 0x00 0x00 

IPV4 Packet---

 len 8

Writing ECHO-REQUEST frame 

AHDLC_TX - transmit frame, protocol 0xc021, length 8  offline 0

0x09 0x02 0x00 0x08 0x00 0x00 0x00 0x00 

- end ECHO-REQUEST Write frame

Receiving packet with good crc value, len 12

0x0a 0x02 0x00 0x08 0xed 0xb6 0x5b 0x05 

LCP Packet - LCP-ECHO REPLY

This is the small “workaround” I did to get the modem working:

diff --git a/netutils/pppd/chat.c b/netutils/pppd/chat.c
index 35ab4c2..637686c 100644
--- a/netutils/pppd/chat.c
+++ b/netutils/pppd/chat.c
@@ -110,7 +110,12 @@ static int chat_check_response(int fd, const char* response, int timeout)
 
   while (*response)
     {
+      /* Just a workaround to get data from modem */
+      printf("chat_check_response read: %c\n", c);
+
       ret = chat_read_byte(fd, &c, timeout);
+      //printf("chat_check_response read: %c\n", c);
+
       if (ret < 0)
         {
           return ret;
@@ -153,6 +158,10 @@ int ppp_chat(int fd, struct chat_script_s *script, int echo)
 
   while (request)
     {
+      /* Wait data arrived before flushing */
+
+      usleep(100000);
+
       chat_flush(fd);
 
       printf("chat: send '%s`\n", request);

How to use a high polling rate mouse on Linux

I just bought a Cooler Master Storm Mizer mouse. Unboxing here:

This mouse is not so expensive and has a good specification (8200 DPI and 1000Hz). But by default Linux uses 125Hz polling rate.

You can change it passing the “mousepoll” parameter to usbhid module.

Edit the file /etc/modprobe.d/modprobe.conf and add:

options usbhid mousepoll=1

The value 1 means 1 milisecond poll period (1000Hz), 2 milisecond = 500Hz, and so on.

Now remove the usbhid module and load it again to get it working:

$ sudo -s
# modprobe -r usbhid && modprobe usbhid

Unplug and plug your mouse again (optional)

Now you can test if everything is working as expected:

$ wget https://github.com/ian-kelling/evhz/raw/master/evhz.c
$ gcc -o evhz evhz.c
$ sudo -s
# ./evhz
Press CTRL-C to exit.

event0: AT Translated Set 2 keyboard
event1: Cooler Master Storm Mizar Mouse
event2: Power Button
event3: Sleep Button
event4: Lid Switch
event5: Power Button
event6: PC Speaker
event7: Dell WMI hotkeys
event8: HDA Digital PCBeep
event9: HDA Intel PCH Mic
event10: HDA Intel PCH Headphone
event11: HDA Intel PCH HDMI/DP,pcm=3
event12: PS/2 Generic Mouse
event13: Cooler Master Storm Mizar Mouse
event14: Video Bus
event15: Video Bus
event16: Laptop_Integrated_Webcam_HD
event17: Cooler Master Storm Mizar Mouse
event18: Cooler Master Storm Mizar Mouse
Cooler Master Storm Mizar Mouse: Latest   500Hz, Average   500Hz
Cooler Master Storm Mizar Mouse: Latest   500Hz, Average   500Hz
Cooler Master Storm Mizar Mouse: Latest   500Hz, Average   500Hz
Cooler Master Storm Mizar Mouse: Latest  1000Hz, Average   625Hz
Cooler Master Storm Mizar Mouse: Latest  1000Hz, Average   700Hz

Very nice!

Source: https://wiki.archlinux.org/index.php/Mouse_polling_rate

WOW!!! Just got more than 1 milions of views!

It was more than 10 years ago when I started my blog to report problems solving about Linux. I couldn’t imagine to have enough stamina to keep it running, but hey! it still here!

Initially all my posts were in Portuguese, but slowly I started introducing some post in English and now almost all my posts are in English. This way many people around the World could read it.

The main subject also changed a little bit, it is not Linux the main topic here. It is embedded systems running NuttX RTOS.

Thank you all for reading my posts and I hope to keep feeding it 😉