2020年5月28日 星期四

Linux kernel module: Add entry in /proc and passing args while insmod

Goal 

Implement a kernel module that can passing parameter when insert module, and add an entry to /proc that can write/read data. In embedded linux often using similar facility to help debug.

Code:


Makefile:



Usage:

1. Insert module and make /proc/Ray entry
 #>sudo insmod test_module.ko entry="Ray" mode=1238
 
2. Write data 
#>echo 123 > /proc/Ray

3. Read data
 #>cat /proc/Ray

2020年5月27日 星期三

DeepSpeech: Speech to text AI model.

  • Overview

"DeepSpeech is an open source Speech-To-Text engine, using a model trained by machine learning techniques based on Baidu’s Deep Speech research paper."
DeepSpeech provide lots of lauange api support, Python Javascript, c, and it's easily use to involve in application

  • Install DeepSpeech

Follow user guide instruction.

  • Demo

Using command line tool to inference sound data.

$> deepspeech --model deepspeech-0.7.0-models.pbmm --audio audio/2830-3980-0043.wav

Output:
Loading model from file deepspeech-0.7.0-models.pbmm
TensorFlow: v1.15.0-24-gceb46aa
DeepSpeech: v0.7.1-0-g2e9c281
Loaded model in 0.0093s.
Loading scorer from files deepspeech-0.7.0-models.scorer
Loaded scorer in 0.00023s.
Running inference.
experience proves this
Inference took 1.480s for 1.975s audio file.
 
The red color string is inference text data of input sound data.

Using Python API to inference sound data.

Output:
your power is sufficient i said sound data


Reference:

2020年5月22日 星期五

Machine Learning Foundations: Exercise 4 Happy and sad image classify model with 99.9% accuracy .

Machine Learning Foundations: Exercise 4 Happy and sad image classify model with 99.9% accuracy:code lab link

Build a mode to classify happy and sad model with convolution neuron network. with more 99.9% accuracy.
 
Note:
  •  Model over-fitting: Near 100% accuracy on training data, but lower accuracy on testing data.
  •  ImageDataGenerator:  Label data automatic using directory name.

Code: 

2020年5月20日 星期三

Conference note: Making C Less Dangerous in the Linux kernel - Kees Cook


In this conference discuss below topic about unsafely C usage, and how Linux kernel has remove or add  facility to detect such condition.

1. Variable Length array
  • Using compiler option to Detect VLA: gcc -W vla
  • Using guard page tor prevent stack overflow. VLA is needed lots of instruction compared to the fixed-size array.
2. Switch case break or non-break
  • Mark all non-breaks with a “fall through” to whether programmer intent to fall through or it's a bug.
  • Compiler support this feature: -Wimplicit-fallthrough
3. Arithmetic overflow detection
  • Using compiler option to detection overflow in compile time
  • Support different warning label: ignore or take as warring
4. Compare different API for string copy
  • The safer string copy function: strscpy().
5. Safe stack - Shadow stack
  • Separate the local variable stack and return address stack
  • Support by hardware:
    • ARM pointer authentication (Sign the return address for distinguish between a local variable and return address 

Reference :

2020年5月18日 星期一

Conference note: Safety vs Security: A Tale of Two Updates - Jeremy Rosen, Smile.fr

Safety and Security are different aspects of a system, briefly discuss the differences between them and challenge to build a system with both concerns.

  • Safety: Proof and make it simple for reliable

    1. Completely define spec.
    2. Proven: Check every state of the system is meet the design.
    3. Change as less as possible: If a bug can solve by period reboot machine, just period reboot machine rather than update the software.

  • Security: Prevent system been using in unwanted way

  1. Fasting iteration: Change the old encryption algorithm to a new one.
  2. Preventive: Need update the spec to face the new challenge.

These two aspects often neglect in embedded system nowadays, especially in customer market. but with more and more device connected to the internet and responsible for critical tasks like healthcare. Designer need to take care of these two fields, Include them in the beginning of designing a system and try to make an optimized combination of them to meet the system standards.


2020年5月17日 星期日

Machine Learning Foundations: Exercise 3 Improve accuracy of MNIST using Convolutions.

Exercise 3: Improve accuracy of MNIST using Convolutions:code lab link

Improve MNIST to 99.8% accuracy or more using only a single convolutional layer and a single MaxPooling 2D.
The filter amount will affect the accuracy and training time.

Code: 

2020年5月16日 星期六

GO: Fixed warning: go env -w GOPATH=... does not override conflicting OS environment variable

Because the GOPATH is OS level setting variable so it can't be set using go env -v cmd.
We need to use OS specify way to modify this PATH variable.


1. Using CMD to set GOPATH variable (Environment: WIN10)
    > setx GOPATH ##YOURPATH##

2. Check the GOPATH been setup 
   > go env 



Reference 
     2. GO/env_write.txt

Linux driver: How to enable dynamic debug at booting time for built-in driver.

 Dynamic debug is useful for debug driver, and can be enable by: 1. Mount debug fs #>mount -t debugfs none /sys/kernel/debug 2. Enable dy...