2025年1月21日 星期二

FN920C04 on Nvidia AGX Orin R36.3

Kernel: 5.15
  • Modify Kernel code
  •   a. drivers/usb/serial/option.coption.c
      b. drivers/net/usb/qmi_wwan.c
      c. drivers/net/usb/cdc_mbim.c
    ...
    /* Telit LN920 */
    {
    	USB_DEVICE_AND_INTERFACE_INFO(0x1bc7, 0x1061, USB_CLASS_COMM,
    				      USB_CDC_SUBCLASS_MBIM,
    				      USB_CDC_PROTO_NONE),
    	.driver_info =
    		(unsigned long)&cdc_mbim_info_avoid_altsetting_toggle,
    },
    
    /* Telit FN920 */
    {
    	USB_DEVICE_AND_INTERFACE_INFO(0x1bc7, 0x10a0, USB_CLASS_COMM,
    				      USB_CDC_SUBCLASS_MBIM,
    				      USB_CDC_PROTO_NONE),
    	.driver_info =
    		(unsigned long)&cdc_mbim_info_avoid_altsetting_toggle,
    },
    ...
    
    
  • FN920C04 FW version
  • at#swpkgv
    49.00.000-B015-P0V.060000
    M0V.060000-B015
    P0V.060000
    A0V.000000-B015
    
  • qmicli+udhcpc, 但系統無法取得IP
  •    #write profile in /etc/qmi-network.conf
        APN=INTERNET #CHT
        APN_USER=
        APN_PASS=
        PROXY=yes
        sudo echo -e "APN=$APN\n" \
            "APN_USER=$APN_USER\n" \
            "APN_PASS=$APN_PASS\n" \
            "PROXY=$PROXY" >/etc/qmi-network.conf
    
    $ qmicli -V
    qmicli 1.32.0
    
    $ sudo qmicli -d /dev/cdc-wdm0 --dms-set-operating-mode='online'
    [/dev/cdc-wdm0] Operating mode set successfully
    
    
    $ sudo ip link set wwan0 down
    
    
    $ sudo echo 'Y' | sudo tee /sys/class/net/wwan0/qmi/raw_ip
    Y
    
    $ sudo ip link set $wwan0 up
    
    
    $ sudo qmicli -d /dev/cdc-wdm0 --wda-get-data-format
    [/dev/cdc-wdm0] Successfully got data format
                       QoS flow header: no
                   Link layer protocol: 'raw-ip'
      Uplink data aggregation protocol: 'disabled'
    Downlink data aggregation protocol: 'disabled'
                         NDP signature: '0'
    Downlink data aggregation max datagrams: '0'
    Downlink data aggregation max size: '0'
    
    
    $ sudo qmi-network /dev/cdc-wdm0 start
    Loading profile at /etc/qmi-network.conf...
        APN: INTERNET
        APN user: unset
        APN password: unset
        qmi-proxy: yes
        IP_TYPE: unset
        PROFILE: unset
    Checking data format with 'qmicli -d /dev/cdc-wdm0 --wda-get-data-format --device-open-proxy'...
    Device link layer protocol retrieved: raw-ip
    Getting expected data format with 'qmicli -d /dev/cdc-wdm0 --get-expected-data-format'...
    Expected link layer protocol retrieved: raw-ip
    Device and kernel link layer protocol match: raw-ip
    Starting network with 'qmicli -d /dev/cdc-wdm0 --wds-start-network=apn='INTERNET'  --client-no-release-cid --device-open-proxy'...
    Saving state at /tmp/qmi-network-state-cdc-wdm0... (CID: 11)
    Saving state at /tmp/qmi-network-state-cdc-wdm0... (PDH: 3767611824)
    Network started successfully
    
    $ sudo qmicli -d /dev/cdc-wdm0 --wds-get-current-settings
    [/dev/cdc-wdm0] Current settings retrieved:
               IP Family: IPv4
            IPv4 address: 25.116.123.173
        IPv4 subnet mask: 255.255.255.252
    IPv4 gateway address: 25.116.123.174
        IPv4 primary DNS: 168.95.1.1
      IPv4 secondary DNS: 168.95.192.1
                     MTU: 1500
                 Domains: none
    
    
    $ sudo udhcpc -i wwan0
    udhcpc: started, v1.30.1
    udhcpc: sending discover
    udhcpc: sending discover
    udhcpc: sending discover
    udhcpc: sending discover
    ...
    ...
    ...
    
    

  • ModemManager
  • 用ModemManager,也不順利,但又說simple connect state 有跑完
    ifconfig沒有看到wwan0
    $ journalctl -xe | grep ModemManager
    or
    $ journalctl -u ModemManager
    
    Jan 15 05:42:31 tegra-ubuntu ModemManager[564]: <warn>  [modem0] couldn't load supported assistance data types: LOC service: general failure
    Jan 15 05:42:31 tegra-ubuntu ModemManager[564]: <info>  [modem0] state changed (unknown -> disabled)
    Jan 15 05:42:31 tegra-ubuntu ModemManager[564]: <info>  [modem0] state changed (disabled -> enabling)
    Jan 15 05:42:31 tegra-ubuntu ModemManager[564]: <info>  [modem0] power state updated: on
    Jan 15 05:42:32 tegra-ubuntu ModemManager[564]: <info>  [modem0] 3GPP registration state changed (unknown -> idle)
    Jan 15 05:42:32 tegra-ubuntu ModemManager[564]: <info>  [modem0] state changed (enabling -> enabled)
    Jan 15 05:42:32 tegra-ubuntu ModemManager[564]: <info>  [modem0] 3GPP registration state changed (idle -> registering)
    Jan 15 05:42:32 tegra-ubuntu ModemManager[564]: <info>  [modem0] 3GPP registration state changed (registering -> home)
    Jan 15 05:42:32 tegra-ubuntu ModemManager[564]: <info>  [modem0] state changed (enabled -> registered)
    Jan 15 05:43:26 tegra-ubuntu ModemManager[564]: <info>  [modem0] simple connect started...
    Jan 15 05:43:26 tegra-ubuntu ModemManager[564]: <info>  [modem0] simple connect state (6/10): register
    Jan 15 05:43:26 tegra-ubuntu ModemManager[564]: <info>  [modem0] simple connect state (7/10): wait to get packet service state attached
    Jan 15 05:43:26 tegra-ubuntu ModemManager[564]: <info>  [modem0] simple connect state (8/10): bearer
    Jan 15 05:43:26 tegra-ubuntu ModemManager[564]: <info>  [modem0] simple connect state (9/10): connect
    Jan 15 05:43:26 tegra-ubuntu ModemManager[564]: <info>  [modem0] state changed (registered -> connecting)
    Jan 15 05:43:26 tegra-ubuntu ModemManager[564]: <info>  [modem0/bearer1] QMI IPv4 Settings:
    Jan 15 05:43:26 tegra-ubuntu ModemManager[564]: <info>  [modem0/bearer1]     address: 10.235.147.133/30
    Jan 15 05:43:26 tegra-ubuntu ModemManager[564]: <info>  [modem0/bearer1]     gateway: 10.235.147.134
    Jan 15 05:43:26 tegra-ubuntu ModemManager[564]: <info>  [modem0/bearer1]     DNS #1: 168.95.1.1
    Jan 15 05:43:26 tegra-ubuntu ModemManager[564]: <info>  [modem0/bearer1]     DNS #2: 168.95.192.1
    Jan 15 05:43:26 tegra-ubuntu ModemManager[564]: <info>  [modem0/bearer1]        MTU: 1500
    Jan 15 05:43:26 tegra-ubuntu ModemManager[564]: <error> mm_utils_bin2hexstr: assertion 'bin != NULL' failed
    Jan 15 05:43:26 tegra-ubuntu ModemManager[564]: <info>  [modem0/bearer1] couldn't start network: QMI protocol error (14): 'CallFailed'
    Jan 15 05:43:26 tegra-ubuntu ModemManager[564]: <info>  [modem0/bearer1] verbose call end reason (2,231): [internal] ip-version-mismatch
    Jan 15 05:43:27 tegra-ubuntu ModemManager[564]: <info>  [modem0/bearer1] reloading stats is supported by the device
    Jan 15 05:43:27 tegra-ubuntu ModemManager[564]: <info>  [modem0] state changed (connecting -> connected)
    Jan 15 05:43:27 tegra-ubuntu ModemManager[564]: <info>  [modem0] simple connect state (10/10): all done
    
  • nmcli
  • 最後用nmcli,把APN加入NetworManager,系統才能拿到IP
    系統reboot後,ModemManager也能拿到IP了(直接ifconfig就有了)
    $ sudo nmcli c add type gsm ifname '*' con-name wwan0 apn internet
    Connection 'wwan0' (8f4ab2a8-d44b-4b57-bb44-dfc9128a9088) successfully added.
    

2024年12月21日 星期六

Neovim+LazyVIM

Neovim, 編譯時,相依滿多東西的,麻煩
a. sudo apt install npm lua-luv-dev lua-lpeg \
   libunibilium-dev libutf8proc-dev libluajit-5.1-dev -y

b. 其它的,缺什麼補什麼
   lua, tree-sitter
   fzf, luarocks(不裝,Checkhealth裡會有WARNING),但它不支援lua 5.5

c. 符號亂碼的話,裝Nerd Font字型:
       nerdfonts
   下載:
       JetBrainsMono Nerd Font
   安裝:
       font
   Terminal:
       要選有Nerd Font的字型,所有符號就能正常下載
       ex: JetBrainsMono Nerd Font

LazyVim
安裝:
    How to Install

Commands for LazyVIM
:checkhealth
:checkhealth mason
:Mason  //初始化 Mason.nvim,通過 mason 可以自動裝各種LSP
LazyVim Extras, 剛進去nvim時,壓一下x


/home/ubuntu/.config/nvim/lua/config/options.lua
-- Tab
vim.opt.tabstop = 4 -- number of visual spaces per TAB
vim.opt.softtabstop = 4 -- number of spacesin tab when editing
vim.opt.shiftwidth = 4 -- insert 4 spaces on a tab
vim.opt.expandtab = true -- tabs are spaces, mainly because of python

-- avante.nvim, views can only be fully collapsed with the global statusline
vim.opt.laststatus = 3
vim.bo.modifiable = false //Some plugins or custom configurations might set certain buffers as non-modifiable. Look for settings like:


Quick keyboard map, <leader>:space key
Switch buffer: ]b, [b
Searching for Keywords: <leader> + /

  • Trace code
  • compile_commands.json, for clangd //A compilation database describes compile commands for a codebase
    放在根專案下
    a. Makefie:
        $ sudo apt install bear
        $ bear -- make
    
    b. CMake:
        $ cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 ..
    
    
    ex:
    .
    ├── compile_commands.json
    ├── include
    │   └── hello.h
    ├── Makefile
    └── src
        ├── hello.c
        └── main.c
    
    go to implementation(gI),它只會回應:[Fzf-lua] No implementations found

    for kernel
    $ make menuconfig
    
    $ make CC=clang
    
    $ python3 ./scripts/clang-tools/gen_compile_commands.py
    


  • avante.nvim
  • Install and Sync
    Create or open ~/.config/nvim/lua/plugins/avante.lua and add this:
    return {
      "yetone/avante.nvim",
      event = "VeryLazy",
      lazy = false,
      version = false, -- Set this to "*" to always pull the latest release version, or set it to false to update to the latest code changes.
      opts = {
        -- add any opts here
        provider = "gemini",
        gemini = {
          model = "gemini-2.0-flash", --see more modles
          timeout = 30000, -- timeout in milliseconds
          temperature = 0, -- adjust if needed
          max_tokens = 4096,
        },
      },
      -- if you want to build from source then do `make BUILD_FROM_SOURCE=true`
      build = "make",
      -- build = "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false" -- for windows
      dependencies = {
        "stevearc/dressing.nvim",
        "nvim-lua/plenary.nvim",
        "MunifTanjim/nui.nvim",
        --- The below dependencies are optional,
        "echasnovski/mini.pick", -- for file_selector provider mini.pick
        "nvim-telescope/telescope.nvim", -- for file_selector provider telescope
        "hrsh7th/nvim-cmp", -- autocompletion for avante commands and mentions
        "ibhagwan/fzf-lua", -- for file_selector provider fzf
        "nvim-tree/nvim-web-devicons", -- or echasnovski/mini.icons
        "zbirenbaum/copilot.lua", -- for providers='copilot'
        {
          -- support for image pasting
          "HakonHarnes/img-clip.nvim",
          event = "VeryLazy",
          opts = {
            -- recommended settings
            default = {
              embed_image_as_base64 = false,
              prompt_for_file_name = false,
              drag_and_drop = {
                insert_mode = true,
              },
              -- required for Windows users
              use_absolute_path = true,
            },
          },
        },
        {
          -- Make sure to set this up properly if you have lazy=true
          "MeanderingProgrammer/render-markdown.nvim",
          opts = {
            file_types = { "markdown", "Avante" },
          },
          ft = { "markdown", "Avante" },
        },
      },
    }
    

    Usage:(support AI list:~/.local/share/nvim/lazy/avante.nvim/lua/avante/providers/)
    1. The sidebar will be divided into 3 sections: Ask, File Name, and Search Results.
    Use the <tab> key to switch.
    
    2. <leader>a  //show the list in the menu
    
    3. $ export GEMINI_API_KEY=your_key
    
    CMD:
    
    1. AvanteClear  //Clear history and reload nvim manually, if "leader a r" didn't work.
    
    


  • 內建bookmark
  • 
    Delete: :delmarks a-z   or  :delmarks!
    
    
ref:
1. keymaps
2. 使用LazyVim将Neovim打造成强大IDE(常用快捷键)
3. gemini.nvim

2024年12月17日 星期二

X-LINUX-AI for STM32MP series

  1. Binary download:
  2.     OpenSTLinux latest (6.0.0), login first

  3. Download image to SD card
  4.     Image_flashing

  5. Install X-AI
  6.     X-LINUX-AI_Starter_package

  7. Others:
  8. a. Performance