基于RPi和LXD的ESP32开发环境

2022-11-22 作者:

对于在板子手动重启时经常把ESP32带进下载模式的问题,LAN8720所需的上/下拉电阻恐怕是最大嫌犯。于是斥巨资近CNY 10元采购了万用板、线仔包和各种直/弯母座,终于搞了MKII —— 重启可靠性问题果然迎刃而解。

过程中,基于lxd的Debian in Debian做了套新环境,顺手也试了试C语言的esp-idf编译,用起来整体感觉很顺手。

RS232 connected with an lxc in raspberry pi 4b (not in pic)

Yes, it actually performs nicely to work on ESP32 development in debian bullseye LXD in Pi OS, no mater you’re working on hardcore C lang based esp-idf or the nice & easy micropython development.

“Hmm… so you need a standard Debian in a derived Debian? “

Well, since I found out that LXD is something very helpful to isolate different needs on different Linux distributions in different containers, while it kinda works pretty much like vm (instead of docker) since it’s easy to config the resources consumption or even usb devices pass-through, and the most important – having its own block storage which can be exported into a single archive.
Then, the only thing I can’t agree with, could be the deep connection with the snapd. Instead of switching to another distribution, such as Arch, I choose to build the LXD of my own (on both Pi OS aarch64 and Ubuntu 22.04 X86_64). Thanks to the good documentation, the stuff (native lxd without the snap crxp) works like a charm.

with Xfce and xrdp, the bullseye lxc can work as an esp dev server quite well

完整阅读本篇»

树莓派监控SANTAK UPS

2022-01-07 作者:

硬件:SANTAK TG-BOX 600 + RPi 4B (2GB) + Huawei ME909s-821

监控服务:NUT(Network UPS Tools)参考文章挺多,就不详解了;Pi上连了4G模块主要是掉电时可能无法得到Wired Ethernet供应,就发个短信而已,不如直接走wwan靠谱省心。

目前用的是standalone模式,回头有空查下文档试试netserver模式,看config文件介绍,猜测是client可以通过server知道市电挂了,从而在server之前关机?

完整阅读本篇»

OpenWrt测试双WAN和双机高可用

2021-12-03 作者:

So here’s a quick example. OpenWrt shows capability to provide business-level internet access reliabilities – with not only load balancing/failover between 2 or more ISPs, but also VRRP based hardware (dual x86 vm in this experiment) level redundancy.

从以下的例子可以看出,OpenWrt基本满足了提供小型商业级Internet访问可靠性的初步要求。它不仅可以在多个ISP之间实现负载均衡以及故障切换,在此基础上同时提供基于VRRP的硬件冗余(本实验中为双x86虚拟机)。

 

先开仨虚拟机,前两台做OpenWrt,可以先做1台,复制1台。注意要安装mwan3和keepalived。

 

双WAN做好后,断开一路wan做测试。这里的wanb,用的是楼道里的不可靠wifi,通过Raspberry Pi向下路由一层转成有线网,能体现出不稳定的ISP接入状态。

本来是两路负载均衡的策略,wanb断开后,5s之内可以让所有对外请求都稳定落在wan上。

 

下一步,把MASTER的br-lan断开,模拟一个路由器硬件直接宕掉。

 

这个切换时间很短,还没反应过来,BACKUP就接管了VIP地址,对外请求几乎不受什么影响。

完整阅读本篇»

DIY带外管理 · 强悍Pi-KVM

2021-09-27 作者:

Let’s talk about the open source IP-KVM (or KVM over IP) solution based on Raspberry Pi 4B, named Pi-KVM, which has sophisticated feature sets that can provide almost same experience like HP ILO or DELL iDRAC, only except the hardware monitoring and err logging.

  • Hardware screen capture with low latency.
  • OTG Keyboard & mouse; Mass Storage Drive emulation.
  • ATX power control (thru Pi GPIO) with some MOSFET relays.
  • RJ-45 and USB serial console port.
  • IPMI BMC, redfish… all those professional server stuff support.
  • Nice and easy-to-use web UI with virtual keyboard, video quality control, key-combination shortcuts and virtual USB drive control.
  • A fully featured, user-customizable Linux OS.

只要玩过专业带外管理,基本就很难接受只有本地键鼠,以及OS之上的RDP和VNC了吧。

随便放两张Dell iDRAC系统截图吧。

今天要聊到的Pi-KVM,在简单廉价的硬件结构上,实现了除硬件子系统监控和告警之外,专业BMC几乎所有功能。

  • 低延迟的显示器信号捕捉和传输(100ms以内)。
  • OTG 键鼠,U盘模拟;给家用机远程load OS不叫事儿。
  • 通过Pi GPIO外加几个继电器实现的ATX电源控制;不说也懂,控制不了电源还叫BMC么。
  • RJ45和USB串口;既能控制路由/交换,也能控制自己。
  • IPMI BMC,redfish… 专业能玩的,它都能玩。
  • 简洁实用的web控制台,软键盘、组合键、粘贴板、视频质量控制、虚拟USB驱动器控制,全乎+易用。
  • 除了所有以上之外,还是个全功能的Arch Linux ARM版本,灵活性刚刚的,这可把专用BMC打趴了吧。

多吹无益,上图。

【注】请忽略裸线,5V和GND用胶带缠了一下,反正不是高压,胶带不绝缘也没关系,别物理刺穿就行;银色金属箔是屏蔽,说明小米的线做工还是靠谱的哈,该有的都没少。

文档制作基于Ventoy的Win10安装盘,全程不用物理U盘,安装Windows。

如果我没说清楚,就重申一遍。类似Dell和HP的专业BMC,可以直接远程挂载ISO装系统。Pi-KVM更狠,借着自己内置存储,直接把U盘/光盘镜像上传,经过物理USB线,模拟一个驱动器插到被控电脑就搞定了,有点爽。

如上所言,被控电脑经USB线连接仿真U盘,BIOS从Linux file-CD启动,无论装什么OS都能够顺利引导。

完整阅读本篇»

树莓派4B频繁遭遇系统假死

2021-07-23 作者:

This post talks about the frequently-happened X hang on the combination of newly updated Raspbian (Pi-OS) Buster and Raspberry Pi 4B, which was NEVER experienced on the Pi 3B (not 3B+) and same OS version after 30 + reboot tests.

PS: Pls note that’s X hang, not kernel hang or panic.

Summary: Pi 4B might has compatbilty issue with unbranded display that provides non-standard EDID info, which Pi 3B obviously has no problem to cooperate with.

本文聊一下最近颇为折磨的Pi 4B图形界面假死问题。当然,所谓假死就是X挂了,但kernel活着,从ssh可以很好的登录管理看日志的情况。

硬件是Pi 4B,操作系统是Raspbian (Pi-OS) Buster 升级最新。在上百次重启中,85%都会X hang。但有趣的是,Pi 3B(不是3B+)用同一块TF卡启动,测试30+次重启,无问题。

既然不是kernel hang,那么故障发生时总要看下log,所得如下:

可以说基本是稳定复现,每次都是Xorg先挂。随后呢,其他进程可能不挂,也可能跟着挂。

就“Xorg Tainted”做了大量的检索,升级OS,升级eeprom都试过,依然无果。只能继续看log继续碰运气。

完整阅读本篇»

Raspbian上snapd狂吃CPU问题

2020-07-22 作者:

To get rid of  snapd  on Raspbian/RaspberryPi OS Buster, since it eats lots of cpu power, especially on the old hardware, like a Pi 2B.

一台年迈的Pi 2B,运行着时时更新的Raspbian Buster,兢兢业业给娃做文件服务器,不亦乐乎。

一天apt dist-upgrade之后,就发现system load频繁升高,系统空载就能吃掉大致一个核的性能。top后画风大致是这样的。

于是很想了解这货在干嘛,消耗这么多脑力,思考人生么?

看起来是想回家拉点什么私货回来(api.snapcraft.io),但还是搞不懂,走io就走io,连续几天24小时一直吃那么多cpu是什么鬼?

完整阅读本篇»