This is a talk which I presented on August 10th, 2017 at Debconf 17 in
Montreal, Canada.
This is a talk which I presented on August 10th, 2017 at Debconf 17 in
Montreal, Canada.
mksh R56 was released with experimental
fixes for the history no longer persisted when HISTFILE near-full and interactive shell
cannot wait on coprocess by PID issues (I hope they do not
introduce any regressioins) and otherwise as a bugfix release. You might
wish to know the $EDITOR selection mechanism in dot.mkshrc
changed. Some more alias characters are allowed again, and POSIX character
classes (for ASCII, and EBCDIC, only) appeared by popular vote.
mksh now has a FAQ; enjoy.
Do feel free to contribute (answers, too, of course).
The jupp text editor has also received
a new release; asides from being much smaller, and updated (mksh too, btw)
to Unicode 10, and some segfault fixes, it features falling back to using
/dev/tty if stdin or stdout is not a terminal (for use on GNU with
find xargs jupp, since they don t have our xargs(1) -o
option yet), a new command to exit nonzero (sometimes, utilities invoking
the generic visual editor need this), and presentation mode .
Presentation mode, crediting Natureshadow, is basically putting your
slides as (UTF-8, with fancy stuff inside) plaintext files into one
directory, with sorting names (so e.g. zero-padded slide numbers as
filenames), presenting them with jupp * in a fullscreen xterm.
You d hit F6 to switch to one-file view first, then present by using
F8 to go forward (F7 to go backward), and, for demonstrations, F9 to
pipe the entire slide through an external command (could be just sh )
offering the previous one as default. Simple yet powerful; I imagine
Sven Guckes would love it, were he not such a vim user.
The new release is offered as source tarball (as usual) and in distribution
packages, but also, again, a Win32 version as PKZIP archive (right-click on
setup.inf and hit I nstall to install it). Note that this comes
with its own (thankfully local) version of the Cygwin32 library (compatible
down to Windows 95, apparently), so if you have Cygwin installed yourself
you re better off compiling it there and using your own version instead.
I ve also released a new DOS version of 2.8 with no code patches but an
updated jupprc; the binary (self-extracting LHarc archive) this
time comes with all resource files, not just jupp s.
Today, the jupprc drop-in file for JOE 3.7 got a matching update
(and some fixes for bugs discovered during that) and I added a new one for
JOE 4.4 (the former being in Debian wheezy, the latter in jessie, stretch
and buster/sid). It s a bit rudimentary (the new shell window functionality
is absent) but, mostly, gives the desired jupp feeling, more so than just
using stock jstar would.
Three years ago, I realized that propellor (my configuration
management system that is configured using haskell) could be used as an
installer for Debian (or other versions of Linux). In
propellor is d-i 2.0, I guessed it would take "a month and adding a few
thousand lines of code".
I've now taken that month, and written
that code, and I
presented the result at DebConf yesterday. I demoed propellor building
a live Debian installation image, and then handed it off to a volenteer
from the audience to
play with its visual user interface
and perform the installation. The whole demo took around 20 minutes,
and ended with a standard Debian desktop installation.
(Video)
The core idea is to reuse the same configuration management system
for several different purposes.
dd.
reading up on rapidjson.
I was reading the docs for rapidjson performance and I like that source buffer is destroyed for performance. I was wrinting JSON parser myself and performance bottleneck seems to be copying and constructing objects.
At some point during my Undergraduate years I lost the habit of using
Libraries. On reflection this is probably Amazon's fault. In recent years
I've tried to get back into the habit of using them.
Using libraries is a great idea if you are trying to lead a more minimalist
life. I am registered to use Libraries in two counties: North Tyneside, where I
live, and Newcastle, where I work. The union of the two counties' catalogues is
pretty extensive. Perhaps surprisingly I have found North Tyneside to offer
both better customer service and a more interesting selection of books.
Sometimes there are still things that are hard to get ahold of. After listening
to BBC Radio 4's documentary The Rise and Fall of
Meritocracy, presented by Toby
Young, I became interested in reading The Rise of the
Meritocracy: an
alarmist, speculative essay that coined the term meritocracy, written by
Toby's father, Michael Young.
The book was not on either catalogue. It is out of print, with the price of
second hand copies fluctuating but generally higher than I am prepared to pay.
I finally managed to find a copy in Newcastle University's
Library. As an associate of the School of
Computing I have access to the Library
services.
It's an interesting read, and I think if it were framed more as a novel than as
an essay it might be remembered in the same bracket as Brave New World or 1984.
Due to some technical issues, it took a slight bit longer than I'd
originally expected; but the first four videos of the currently running
DebConf 17 conference are
available.
Filenames are based on the talk title, so that should be reasonably easy
to understand. I will probably add an RSS feed (like we've done for
DebConf
16)
to that place some time soon as well, but code for that still needs to
be written.
Meanwhile, we're a bit behind on the reviewing front, with (currently)
34 talks still needing review. If you're interested in helping out,
please join the #debconf-video channel on OFTC and ask what you can do.
This is something which you can do from home if you're interested, so
don't be shy! We'd be happy for your help.
I was assigned 15 hours of work by Freexian's Debian LTS initiative
and worked 14 hours. I will carry over 1 hour to the next month.
I prepared and released an update on the Linux 3.2 longterm stable
branch (3.2.91), and started work on the next update. However, I
didn't make any uploads to Debian this month.
My monthly report covers a large part of what I have been doing in the free software world. I write it for my donors (thanks to them!) but also for the wider Debian community because it can give ideas to newcomers and it s one of the best ways to find volunteers to work with me on projects that matter to me.
Debian LTS
This month I was allocated 12 hours but I only managed to work for 7 hours (due to vacation and unanticipated customer work). I gave back the remaining hours to the pool as I didn t want to carry them over for August which will be also short due to vacation (BTW I m not attending Debconf). I spent my 7 hours doing CVE triaging during the week where I was in charge of the LTS frontdesk (I committed 22 updates to the security tracker). I did publish DLA-1010-1 on vorbis-tools but the package update had been prepared by Petter Reinholdtsen.
Misc Debian work
zim. I published an updated package in experimental (0.67~rc2-2) with the upstream bug fixes on the current release candidate. The final version has been released during my vacation and I will soon upload it to unstable.
Debian Handbook. I worked with Petter Reinholdtsen to finalize the paperback version of the Norwegian translation of the Debian Administrator s Handbook (still covering Debian 8 Jessie). It s now available.
Bug reports. I filed a few bugs related to my Kali work. #868678: autopkgtest s setup-testbed script is not friendly to derivatives. #868749: aideinit fails with syntax errors when /etc/debian_version contains spaces.
debian-installer. I submitted a few d-i patches that I prepared for a customer who had some specific needs (using the hd-media image to boot the installer from an ISO stored in an LVM logical volume). I made changes to debian-installer-utils (#868848), debian-installer (#868852), and iso-scan (#868859, #868900).
Thanks
See you next month for a new summary of my activities.
No comment Liked this article? Click here. My blog is Flattr-enabled.
I have been in Montreal only for a day. Yesterday night, I left DebConf just after I finished presenting the Continuous Key-Signing Party introduction to go out with a long-time friend from Mexico and his family. We went to the Mont Royal park, from where you can have a beautiful city view:
What I was most amazed of as a Mexico City dweller is of the sky, of the air... Not just in this picture, but as we arrived, or later when a full moon rose. This city has beautiful air, and a very beautiful view. We later went for dinner to a place I heartfully recommend to other non-vegetarian attendees:
Portuguese-style grill. Delicious. Of course, were I to go past it, I'd just drive on (as it had a very long queue waiting to enter). The secret: Do your request on the phone. Make a short queue to pick it up. Have somebody in the group wait for a table, or eat at the nearby Parc Lafontaine. And... Thoroughly enjoy :-)
Anyway, I'm leaving for the venue, about to use the Bixi service for the first time. See you guys soon! (if you are at DebConf17, of course. And you should all be here!)
| Attachment | Size |
|---|---|
| Montreal1.jpeg | 112.83 KB |
| Montreal2.jpeg | 118.2 KB |
| Poule.jpeg | 118.85 KB |
A few years ago, I started to write software which primary
audience is going to be blind musicians. I did a small presentation
of the UI at DebConf15.
Most of the functionality
is in a compiler-alike backend. But eventually, I wanted to create
a user interface to improve the interactive experience.
So, the problem again: which toolkit to choose which would be accessible
on most platforms? Last time I needed to solve a similar
problem, I used Java/Swing. This has its problems, but
it actually works on Windows, Linux and (supposedly) Mac.
This time around, my implementation language is C++, so Swing
didn't look that interesting. It appears there is not
much that fullfils these requirements. Qt looked like it could.
But since I had my bad experiences already with Qt claiming
accessibility they really never implemented, I was at least
a bit cautious. Around 10 years ago, when Qt 4 was released,
I found that the documentation claimed that Qt4 was accessible
on Linux, but it really never was until a very late 4.x release.
This information was a blatant lie, trying to lure uninformed programmers
into using Qt, much to the disservice of their disabled users.
If you ask a random blind Windows user who knows a bit about toolkits,
they will readily tell you that they hate every app written in Qt.
With this knowledge, and the spirit of "We can change the world"
I wrote a private mail to the person responsible for maintaining Qt
accessibility. I explained to them that I am about to choose Qt as the UI
platform for my program, and that my primary audience is users that
rely on Accessibility. I also explained that cross-platform support
(esp. good support on Windows) is a necessary requirement for
my project. I basically got a nice marketing speak answer
back, but when I read it back then, I didn't fully realize that just yet.
The tone basicallly: "No problem. Qt works on Linux, Mac and Windows,
and if you find any problems, just report them to us and we are going
to fix them." Well, I was aware that I am not a paying
customer of Qt Company, so the promise above is probbably
a bit vague (I thought), but still, it sounded quite encouraging.
So off I went, and started to learn enough Qt to implement
the simple user interface I wanted. First tests on
Linux seemed to work, that is nice. After a while, I started
to test on Windows. And BANG, of course, there is a "hidden" problem.
The most wide-spread (commercial) screen reader used by most blind people
somehow does not see the content of text entry widgets.
This was and still is a major problem for my project. I have a number
of text entry fields in my UI. Actually, the main part of
the UI is a simple editor, so you might see the problem already.
So some more testing was done, just to realize that yes, text entry
fields indeed do not work with the most widely used screen
reader on Windows. While other screen readers seemed to work (NVDA)
it is simply not feasable to ask my future users to switch to a different
screen reader just for a single program. So I either needed to get JAWS
fixed, or drop Qt.
Well, after a lot of testing, I ended up submitting a bug to the Qt tracker.
That was a little over a year ago.
The turnaround time of private mail was definitely faster.
And now I get a reply to my bug explaining that JAWS was
never a priority, still is not, and that my problem will
probably go away after a rewrite which has no deadline yet.
Why did I expect this already?
At least now I know why no blind users wants to have any Qt on their machines.
If you want to write cross-platform accessible software:
You definitely should not use Qt. And no other Free Software
toolkit for that matter, because they basically all dont give a shit
about accessibility on non-Linux platforms. Yes, GTK has
a Windows port, but that isn't accessible at all.
Yes, wxWindows has a Windows port, but that has problems with, guess what, text entry fields (at least last time I checked).
Free Software is NOT about Accessibility or equality.
I see evidence for that claim since more then 15 years now.
It is about coolness, self-staging, scratch-your-own-itchness and things like that.
When Debian released Jessie, I was told that something like
Accessibility is not important enough to delay the release. If GNOME
just broke all the help system by switching to not-yet-accessible
webkit, that is just bad luck, I was told. But it is outside
of the abilities of package maintainers to ensure that what we ship is
accessible.
I hereby officially give up. And I admit my own
stupidity. Sorry for claiming Free Software would be a good thing for the world.
It is definitely not for my kin. If Free Software
ever takes over, the blind will be unable to use their computers.
Don't get me wrong. I love my command-line.
But as the well-known saying goes: "Free Software
will be ready for the desktop user, perhaps, next year?"
The scratch-your-own-itch philosophy simply doesn't work
together with a broad list of user requirements.
If you want to support users with disabilities, you probably
should not rely on hippie coders right now.
I repeat: If you want to write compliant software, that would
be also useable to people with disabilities, you can not use
Qt. For now, you will need to write a native UI for every
platform you want to support. Oh, and do not believe
Qt Company marketing texts, your users will suffer if you do.
ntpd had stopped working on my machine for some reason,
I found that systemd
provides an easier way to keep time synchronized.
ntpd daemon anymore. The built-in systemd-timesyncd can do the basic
time synchronization job just fine.
However, I noticed that the daemon wasn't actually running:
$ systemctl status systemd-timesyncd.service
systemd-timesyncd.service - Network Time Synchronization
Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/systemd-timesyncd.service.d
disable-with-time-daemon.conf
Active: inactive (dead)
Condition: start condition failed at Thu 2017-08-03 21:48:13 PDT; 1 day 20h ago
Docs: man:systemd-timesyncd.service(8)
referring instead to a mysterious "failed condition". Attempting to restart
the service did provide more details though:
$ systemctl restart systemd-timesyncd.service
$ systemctl status systemd-timesyncd.service
systemd-timesyncd.service - Network Time Synchronization
Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/systemd-timesyncd.service.d
disable-with-time-daemon.conf
Active: inactive (dead)
Condition: start condition failed at Sat 2017-08-05 18:19:12 PDT; 1s ago
ConditionFileIsExecutable=!/usr/sbin/ntpd was not met
Docs: man:systemd-timesyncd.service(8)
The above check for the presence of /usr/sbin/ntpd points to a conflict
between ntpd and systemd-timesyncd. The solution of course is to remove
the former before enabling the latter:
apt purge ntp
ntp package has been removed, it is time to enable NTP support in
timesyncd.
Start by choosing the NTP server pool nearest
you and put it in /etc/systemd/timesyncd.conf. For example, mine reads
like this:
[Time]
NTP=ca.pool.ntp.org
before restarting the daemon:
systemctl restart systemd-timesyncd.service
That may not be enough on your machine though. To check whether or not the
time has been synchronized with NTP servers, run the following:
$ timedatectl status
...
Network time on: yes
NTP synchronized: no
RTC in local TZ: no
If NTP is not enabled, then you can enable it by running this command:
timedatectl set-ntp true
Once that's done, everything should be in place and time should be kept
correctly:
$ timedatectl status
...
Network time on: yes
NTP synchronized: yes
RTC in local TZ: no
I have been working with STM32 chips on-and-off for at least eight, possibly
closer to nine years. About as long as ST have been touting them around. I
love the STM32, and have done much with them in C. But, as my
previous two posts may have hinted, I
would like to start working with Rust instead of C. To that end, I have
been looking with great joy at the work which Jorge Aparicio has
been doing around Cortex-M3 and Rust. I've had many comments in person at
Debconf, and also several people mention on Twitter, that they're glad more
people are looking at this. But before I can get too much deeper into trying
to write my USB stack, I need to sort a few things from what Jorge has done as
demonstration work.
/* Enable HSE */
RCC_HSEConfig(RCC_HSE_ON);
/* Wait till HSE is ready */
HSEStartUpStatus = RCC_WaitForHSEStartUp();
if (HSEStartUpStatus == SUCCESS)
/* Enable Prefetch Buffer */
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
/* Flash 2 wait state */
FLASH_SetLatency(FLASH_Latency_2);
/* HCLK = SYSCLK */
RCC_HCLKConfig(RCC_SYSCLK_Div1);
/* PCLK2 = HCLK */
RCC_PCLK2Config(RCC_HCLK_Div1);
/* PCLK1 = HCLK/2 */
RCC_PCLK1Config(RCC_HCLK_Div2);
/* ADCCLK = PCLK2/6 */
RCC_ADCCLKConfig(RCC_PCLK2_Div6);
/* PLLCLK = 8MHz * 9 = 72 MHz */
RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);
/* Enable PLL */
RCC_PLLCmd(ENABLE);
/* Wait till PLL is ready */
while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
/* Select PLL as system clock source */
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
/* Wait till PLL is used as system clock source */
while (RCC_GetSYSCLKSource() != 0x08)
fn make_go_faster(rcc: &RCC, flash: &FLASH)
rcc.cr.modify( _, w w.hseon().enabled());
while !rcc.cr.read().hserdy().is_ready()
flash.acr.modify( _, w w.prftbe().enabled());
flash.acr.modify( _, w w.latency().two());
rcc.cfgr.modify( _, w w
.hpre().div1()
.ppre2().div1()
.ppre1().div2()
// .adcpre().bits(8)
.pllsrc().external()
.pllxtpre().div1()
.pllmul().mul9()
);
rcc.cr.modify( _, w w.pllon().enabled());
while rcc.cr.read().pllrdy().is_unlocked()
rcc.cfgr.modify( _,w w.sw().pll());
while !rcc.cfgr.read().sws().is_pll()
unsafe function (bits()) and I'm trying to steer clear of
unsafe for now. Still, I don't need the ADC immediately, so I'm okay with
this.
By using this function in the beginning of the init() function of the
blinky example, I can easily demonstrate the clock is going faster since the
LED blinks more quickly.
This function demonstrates just how simple it is to take bit-manipulation from
the C code and turn it into (admittedly bad looking) Rust with relative ease
and without any of the actual bit-twiddling. I love it.
make_go_faster() function to the serial loopback example, it
simply fails to work because now the bus which the USART1 peripheral is
connected to (APB2) is going at a different speed from the expected power-on
default of 8MHz. If you remember from the function, we did .hpre().div1()
which set HCLK to 72MHz, then .ppre1().div2() which sets the APB1 bus
clock to be HCLK divided by 2, and .ppre2().div1() which sets APB2 bus
clock to be HCLK. This means that we'd need to alter src/lib.rs to
reflect these changes in the clock frequences and in theory loopback would
start working once more.
It'd be awkward to try and demonstrate all that to you since I only have a
phone camera to hand, but if you own a blue-pill then you can clone Jorge's
repo and have a go yourself and see that I'm not bluffing you.
With all this done, it'll be time to see if we can bring the USB peripheral
in the STM32 online, and that will be the topic of my next post in this
discovery series.
I am still far from being a professor, but I recently got a glimps of what awaits you in that role
From: Sebastian R. < @gmail.com>Nice. I like when people learn from my lectures. The introduction is a bit werid, but ok, maybe this guy had some bad experiences. Strangley, I don t see a mistake in the material, so I respond:
To: joachim@cis.upenn.edu
Subject: re: Errors I've spotted a basic error in your course on Haskell (https://www.seas.upenn.edu/~cis194/fall16/). Before I proceed, it's cool if you're not receptive to errors being indicated; I've come across a number of professors who would rather take offense than admit we're all human and thus capable of making mistakes... My goal is to find a resource that might be useful well into the future, and a good indicator of that is how responsive the author is to change. In your introduction note you have written:n contrast to a classical intro into Haskell, we do not start with numbers, booleans, tuples, lists and strings, but we start with pictures. These are of course library-defined (hence the input CodeWorld) and not part of the language . But that does not make them less interesting, and in fact, even the basic boolean type is library defined it just happens to be the standard library.Howeverm there is noinput CodeWorldin the code above. Have you been made aware of this error earlier? Regards, ...
From: Joachim Breitner <noscript>joachim at cis dot upenn dot edu</noscript>A while later, I receive this response:
To: Sebastian R. < @gmail.com>
Subject: Re: Errors Dear Sebastian, thanks for pointing out errors. But the first piece of code under Basic Haskell starts withso I am not sure what you are referring to. Note that these are lecture notes, so you have to imagine a lecturer editing code live on stage along with it. If you only have the notes, you might have to infer a few things. Regards, Joachim-# LANGUAGE OverloadedStrings #- import CodeWorld
From: Sebastian R. < @gmail.com>I am a bit reminded of Sean Spicer they re not my words! but clearly I am missing something. And indeed I am: In the code snippet, I wrote correctly
To: Joachim Breitner <noscript>joachim at cis dot upenn dot edu</noscript>
Subject: Re: Errors Greetings, Joachim. Kindly open the lecture slides and search for "input CodeWorld" to find the error; it is not in the code, but in the paragraph that implicitly refers back to the code. You might note that I quoted this precisely from the lectures... and so I repeat myself... this came from your lectures; they're not my words!In contrast to a classical intro into Haskell, we do not start with numbers, booleans, tuples, lists and strings, but we start with pictures. These are of course library-defined (hence the input CodeWorld) and not part of the language . But that does not make them less interesting, and in fact, even the basic boolean type is library defined it just happens to be the standard library.This time around, I've highlighted the issue. I hope that made it easier for you to spot... Nonetheless, I got my answer. Don't reply if you're going to fight tooth and nail about such a basic fix; it's simply a waste of both of our time. I'd rather learn from somewhere else... On Tue, Aug 1, 2017 at 11:19 PM, Joachim Breitner <noscript>joachim at cis dot upenn dot edu</noscript> wrote:
import CodeWorld, but in the text I had input CodeWorld. I probably did write LaTeX before writing the lecture notes. Well, glad to have that sorted out. I fixed the mistake and wrote back:
From: Joachim Breitner <noscript>joachim at cis dot upenn dot edu</noscript>(And it seems I now made the inverse typo, writing import instead of input . Anyways, I did not think of this any more until a few days later, when I found this nice message in my mailbox:
To: Sebastian R. < @gmail.com>
Betreff: Re: Errors Dear Sebastian, nobody is fighting, and I see the mistake now: The problem is not that the line is not in the code, the problem is that there is a typo in the line and I wrote input instead of import . Thanks for the report, although you did turn it into quite a riddle a simple you wrote import when it should have been import would have been a better user of both our time. Regards, Joachim Am Donnerstag, den 03.08.2017, 13:32 +1000 schrieb Sebastian R.:
From: Sebastian R. < @gmail.com>Well, I chose to be amused by this, and I am sharing my amusement with you.
To: Joachim Breitner <noscript>joachim at cis dot upenn dot edu</noscript>
Subject: Re: Errorsa simple you wrote import when it should have been import would have been a better user of both our time.We're both programmers. How about I cut ALL of the unnecessary garbage and just tell you to s/import/input/ on that last quotation (the thing immediately before this paragraph, in case you didn't know). I blatantly quoted the error, like this:In your introduction note you have written:Since that apparently wasn't clear enough, in my second email to you I had to highlight it like so:n contrast to a classical intro into Haskell, we do not start with numbers, booleans, tuples, lists and strings, but we start with pictures. These are of course library-defined (hence the input CodeWorld) and not part of the language . But that does not make them less interesting, and in fact, even the basic boolean type is library defined it just happens to be the standard library.Howeverm there is noinput CodeWorldin the code above.You might note that I quoted this precisely from the lectures... and so I repeat myself... this came from your lectures; they're not my words!I'm not sure if you're memeing at me or not now, but it seems either your reading comprehension, or your logical deduction skills might be substandard. Unfortunately, there isn't much either of us can do about that, so I'm happy to accept that some people will be so stupid; after all, it's to be expected and if we don't accept that which is to be expected then we live our lives in denial. Happy to wrap up this discusson here, Seb... On Fri, Aug 4, 2017 at 12:22 AM, Joachim Breitner <noscript>joachim at cis dot upenn dot edu</noscript> wrote:In contrast to a classical intro into Haskell, we do not start with numbers, booleans, tuples, lists and strings, but we start with pictures. These are of course library-defined (hence the input CodeWorld) and not part of the language . But that does not make them less interesting, and in fact, even the basic boolean type is library defined it just happens to be the standard library.This time around, I've highlighted the issue. I hope that made it easier for you to spot...
I realised recently that my laptop isn't set up to send TRIM or
DISCARD commands to its SSD. That means the SSD firmware has a harder
time doing garbage collection (see whe linked Wikipedia page for more
details.)
After some searching, I found two articles by Christopher Smart:
one, update. Those, plus some addition reading of
documentation, and a little experimentation, allowed me to do this.
Since the information is a bit scattered, here's the details, for
Debian stretch, as much for my own memory as to make sure this is
collected into one place.
,discard to the fourth column on relevant lines in
/etc/crypttab. For me, this means the fourth column should be
luks,discard./etc/lvm/lvm.conf that says issue_discards to enable
it (assign 1 instead of 0).rd.luks.options=discard to the GRUB_CMDLINE_LINUX_DEFAULT
value in /etc/default/grubsudo update-grubsudo update-initramfs -usudo fstrim -av - if this works, you're good! If it gives you
errors, then you get to debug. I have no idea what I'm talking
about./usr/share/doc/util-linux/examples/fstrim.* to
/etc/systemd/system and run sudo systemctl enable fstrim.timer.
This will tell systemd to run fstrim every week. (If you don't use
systemd you'll have to adapt the systemd bits mentioned here. I've
no idea how.)
Previously we talked about all the different kinds of
descriptors which USB devices use to communicate their capability. This is
important stuff because to write any useful USB device firmware we need to
be able to determine how to populate our descriptors. However, having that
data on the device is entirely worthless without an understanding of how it
gets from the device to the host so that it can be acted upon. To understand
that, let's look at the USB wire protocol.
Note, I'll again be talking mostly about USB2.0 low- and full-speed. I believe that high speed is approximately the same but with faster wires, except not quite that simple.
| Packet type | Purpose |
|---|---|
| Token Packet | When the host wishes to send a message to the Control endpoint to configure the device, read data IN, or write data OUT, it uses this to start the transaction. |
| Data(0/1) Packet | Following a Setup, In, or Out token, a Data packet is a transfer of data (in either direction). The 0 and 1 alternate to provide a measure of confidence against lost packets. |
| Handshake Packet | Following a data packet of some kind, the other end may ACK the packet (all was well), NAK the packet (report that the device cannot, temporarily, send/receive data, or that an interrupt endpoint isn't triggered), or STALL the bus in which case the host needs to intervene. |
| Start of Frame | Every 1ms (full-speed) the host will send a SOF packet which carries a frame number. This can be used to help keep time on very simple devices. It also divides the bus into frames within which bandwidth is allocated. |
OUT0)GET_DESCRIPTOR for the device
descriptorGET_DESCRIPTOR request and prepares the device descriptor for transmission.
The transmission occurs as the next transaction on the bus. In this example,
we're assuming 8 byte maximum transmission sizes, for illustrative purposes.
IN0)IN0)OUT0)ACK the device prepares IN0 to transmit the descriptor,
readying whatever low level device stack there is with a pointer to the
descriptor and its length in bytes.ACK the low levels are still thinking.ACK the transmission from IN0 is complete and the endpoint
no longer expects to transfer data.ACK the control transaction is entirely complete.| Field Name | Byte start | Byte length | Encoding | Meaning |
|---|---|---|---|---|
| bmRequestType | 0 | 1 | Bitmap | Describes the kind of request, and the target of it. See below. |
| bRequest | 1 | 1 | Code | The request code itself, meanings of the rest of the fields vary by bRequest |
| wValue | 2 | 2 | Number | A 16 bit value whose meaning varies by request type |
| wIndex | 4 | 2 | Number | A 16 bit value whose meaning varies by request type but typically encodes an interface number or endpoint. |
| wLength | 6 | 2 | Number | A 16 bit value indicating the length of the transfer to come. |
bRequest is essentially a switch against which multiple kinds of setup
packet are selected between, here's the meanings of a few...
| Field Name | Value | Meaning |
|---|---|---|
| bmRequestType | 0x08 | Data direction is IN (from device to host), recipient is the device |
| bRequest | 0x06 | GET_DESCRIPTOR (in this instance, the device descriptor is requested) |
| wValue | 0x0001 | This means the device descriptor |
| wIndex | 0x0000 | Irrelevant, there's only 1 device descriptor anyway |
| wLength | 12 | This is the length of a device descriptor (12 bytes) |
| Field Name | Value | Meaning |
|---|---|---|
| bmRequestType | 0x00 | Data direction is OUT (from host to device), recipient is the device |
| bRequest | 0x05 | SET_ADDRESS (Set the device's USB address) |
| wValue | 0x00nn | The address for the device to adopt (max 127) |
| wIndex | 0x0000 | Irrelevant for address setting |
| wLength | 0 | There's no data transfer expected for this setup operation |
IN or OUT tokens and if the endpoint is zero, the low level
stack will handle it once more.
One final thing worth noting about SET_ADDRESS is that it doesn't take
effect until the completion of the zero-length "status" transaction following
the setup transaction. As such, the status request from the host will still
be sent to address zero (the default for new devices).
RESET state and so
the first event a device sees is a RESET which causes it to set its address
to zero, clear any endpoints, clear the configuration, and become ready for
control transfers. Shortly after this, the device will become suspended.
Next, the host kicks in and sends a port reset of around 30ms. After this, the
host is ready to interrogate the device.
The host sends a GET_DESCRIPTOR to the device, whose address at this point is
zero. Using the information it receives from this, it can set up the host-side
memory buffers since the device descriptor contains the maximum transfer size
which the device supports.
The host is now ready to actually 'address' the device, and so it sends another
reset to the device, again around 30ms in length.
The host sends a SET_ADDRESS control request to the device, telling it that
its new address is nn. Once the acknowledgement has been sent from the host
for the zero-data status update from the device, the device sets its internal
address to the value supplied in the request. From now on, the device shall
respond only to requests to nn rather than to zero.
At this point, the host will begin interrogating further descriptors, looking
at the configuration descriptors and the strings, to build its host-side
representation of the device. These will be GET_DESCRIPTOR and
GET_STRING_DESCRIPTOR requests and may continue for some time.
Once the host has satisfied itself that it knows everything it needs to about
the device, it will issue a SET_CONFIGURATION request which basically starts
everything up in the device. Once the configuration is set, interrupt
endpoints will be polled, bulk traffic will be transferred, Isochronous
streams begin to run, etc.
D+. This is the way that a device
signals to the host that it is present, and that it wants to speak at
full-speed. If the pullup were on D- then it would be a low-speed device.
High speed devices need a little more complexity which I'm not going to go into
for today.
The USB lines connect to pins PA11 and PA12 which are the USB pins on the
STM32 on the board. Since USB is quite finicky, the STM32 doesn't let you
remap that function elsewhere, so this is all looking quite good for us so far.
The specific STM32 on the blue-pill is the STM32F103C8T6. By viewing its
product page on ST's website we can find the
reference manual for the part. Jumping to section 23 we learn that
this STM32 supports full-speed USB2.0 which is convenient given the past
article and a half. We also learn it supports up to eight endpoints active at
any one time, and offers double-buffering for our bulk and isochronous
transfers. It has some internal memory for packet buffering, so it won't use
our RAM bandwidth while performing transfers, which is lovely.
I'm not going to distill the rest of that section here, because there's a large
amount of data which explains how the USB macrocell operates. However useful
things to note are:
IN OUT and SETUP transfers work.
Dear conference organizers,
In this day and age, people stream conferences and other events over the
Internet. Most of the Internet happens to be in a different timezone from
yours (it's crazy, I know!). This means that if you publish a schedule,
please say which timezone it's in. We've even got this thing called
JavaScript now, which allows you to also convert times to the user's local
timezone (the future is now!), so you might want to consider using it. :-)
(Yes, this goes for you, DebConf,
and also for you, Assembly.)
I ran my little analysis program written last year to provide a nice map on the DebConf17 key signing party, based on the . What will you find if you go there?
I have been spending time with Jorge Aparicio's
RTFM for Cortex M3 framework for writing Rust to target Cortex-M3
devices from Arm (and particularly the STM32F103 from ST Microelectronics).
Jorge's work in this area has been of interest to me ever since I discovered
him working on this stuff a while ago. I am very tempted by the idea of being
able to implement code for the STM32 with the guarantees of Rust and the
language features which I have come to love such as the trait system.
I have been thinking to myself that, while I admire and appreciate the work
done on the GNUK, I would like to, personally, have a go at implementing
some kind of security token on an STM32 as a USB device. And with the advent
of the RTFM for M3 work, and Jorge's magical tooling to make it easier to
access and control the registers on an M3 microcontroller, I figured it'd be
super-nice to do this in Rust, with all the advantages that entails in terms
of isolating unsafe behaviour and generally having the potential to be more
easily verified as not misbehaving.
To do this though, means that I need a USB device stack which will work in the
RTFM framework. Sadly it seems that, thus-far, only Jorge has been working on
drivers for any of the M3 devices his framework supports. And one person can
only do so much. So, in my infinite madness, I decided I should investigate
the complexity of writing a USB device stack in Rust for the RTFM/M3 framework.
(Why I thought this was a good idea is lost to the mists of late night
Googling, but hey, it might make a good talk at the next conference I go to).
As such, this blog post, and further ones along these lines, will serve as a
partial tour of what I'm up to, and a partial aide-memoir for me about learning
USB. If I get something horribly wrong, please DO contact me to correct
me, otherwise I'll just continue to be wrong. If I've simplified something but
it's still strictly correct, just let me know if it's an oversimplification
since in a lot of cases there's no point in me putting the full details into a
blog posting. I will mostly be considering USB2.0 protocol details but only
really for low and full speed devices. (The hardware I'm targetting does
low-speed and full-speed, but not high-speed. Though some similar HW does
high-speed too, I don't have any to hand right now)
IN to the host or OUT to the device. Endpoints are not bidirectional,
but the in and out endpoints do overlap in numbering. There is a special pair
of endpoints, IN0 and OUT0 which, between them, form what I will call the
device control endpoints. The device control endpoints are important since
every USB device MUST implement them, and there are a number of well
defined messages which pass over them to control the USB device. In theory a
bare minimum USB device would implement only the device control endpoints.
| Field Name | Byte start | Byte length | Encoding | Meaning |
|---|---|---|---|---|
| bLength | 0 | 1 | Number | Size of the descriptor in bytes (18) |
| bDescriptorType | 1 | 1 | Constant | Device Descriptor (0x01) |
| bcdUSB | 2 | 2 | BCD | USB spec version compiled with |
| bDeviceClass | 4 | 1 | Class | Code, assigned by USB org (0 means "Look at interface descriptors", common value is 2 for CDC) |
| bDeviceSubClass | 5 | 1 | SubClass | Code, assigned by USB org (usually 0) |
| bDeviceProtocol | 6 | 1 | Protocol | Code, assigned by USB org (usually 0) |
| bMaxPacketSize | 7 | 1 | Number | Max packet size for IN0/OUT0 (Valid are 8, 16, 32, 64) |
| idVendor | 8 | 2 | ID | 16bit Vendor ID (Assigned by USB org) |
| idProduct | 10 | 2 | ID | 16bit Product ID (Assigned by manufacturer) |
| bcdDevice | 12 | 2 | BCD | Device version number (same encoding as bcdUSB) |
| iManufacturer | 14 | 1 | Index | String index of manufacturer name (0 if unavailable) |
| iProduct | 15 | 1 | Index | String index of product name (0 if unavailable) |
| iSerialNumber | 16 | 1 | Index | String index of device serial number (0 if unavailable) |
| bNumConfigurations | 17 | 1 | Number | Count of configurations the device has. |
bcdUSB and bcdDevice fields is interesting too. It is
of the form 0xMMmm where MM is the major number, mm the minor. So USB2.0
is encoded as 0x0200, USB1.1 as 0x0110 etc. If the device version is 17.36
then that'd be 0x1736.
Other fields of note are bDeviceClass which can be 0 meaning that
interfaces will specify their classes, and idVendor/idProduct which between
them form the primary way for the specific USB device to be identified. The
Index fields are indices into a string table which we'll look at later. For
now it's enough to know that wherever a string index is needed, 0 can be
provided to mean "no string here".
The last field is bNumConfigurations and this indicates the number of ways in
which this device might function. A USB device can provide any number of these
configurations, though typically only one is provided. If the host wishes to
switch between configurations then it will have to effectively entirely quiesce
and reset the device.
The next kind of descriptor is the configuration descriptor. This one is much
shorter, but starts with the same two fields:
| Field Name | Byte start | Byte length | Encoding | Meaning |
|---|---|---|---|---|
| bLength | 0 | 1 | Number | Size of the descriptor in bytes (9) |
| bDescriptorType | 1 | 1 | Constant | Configuration Descriptor (0x02) |
| wTotalLength | 2 | 2 | Number | Size of the configuration in bytes, in total |
| bNumInterfaces | 4 | 1 | Number | The number of interfaces in this configuration |
| bConfigurationValue | 5 | 1 | Number | The value to use to select this configuration |
| iConfiguration | 6 | 1 | Index | The name of this configuration (0 for unavailable) |
| bmAttributes | 7 | 1 | Bitmap | Attributes field (see below) |
| bMaxPower | 8 | 1 | Number | Maximum bus power this configuration will draw (in 2mA increments) |
bmAttributes field which tells the
host some useful information. Bit 7 must be set, bit 6 is set if the device
would be self-powered in this configuration, bit 5 indicates that the device
would like to be able to wake the host from sleep mode, and bits 4 to 0 must be
unset.
The bMaxPower field is interesting because it encodes the power draw of the
device (when set to this configuration). USB allows for up to 100mA of draw
per device when it isn't yet configured, and up to 500mA when configured. The
value may be used to decide if it's sensible to configure a device if the host
is in a low power situation. Typically this field will be set to 50 to
indicate the nominal 100mA is fine, or 250 to request the full 500mA.
Finally, the wTotalLength field is interesting because it tells the host the
total length of this configuration, including all the interface and endpoint
descriptors which make it up. With this field, the host can allocate enough
RAM to fetch the entire configuration descriptor block at once, simplifying
matters dramatically for it.
Each configuration has one or more interfaces. The interfaces group some
endpoints together into a logical function. For example a configuration for
a multifunction scanner/fax/printer might have an interface for the scanner
function, one for the fax, and one for the printer. Endpoints are not shared
among interfaces, so when building this table, be careful.
Next, logically, come the interface descriptors:
| Field Name | Byte start | Byte length | Encoding | Meaning |
|---|---|---|---|---|
| bLength | 0 | 1 | Number | Size of the descriptor in bytes (9) |
| bDescriptorType | 1 | 1 | Constant | Interface Descriptor (0x04) |
| bInterfaceNumber | 2 | 1 | Number | The number of the interface |
| bAlternateSetting | 3 | 1 | Number | The interface alternate index |
| bNumEndpoints | 4 | 1 | Number | The number of endpoints in this interface |
| bInterfaceClass | 5 | 1 | Class | The interface class (USB Org defined) |
| bInterfaceSubClass | 6 | 1 | SubClass | The interface subclass (USB Org defined) |
| bInterfaceProtocol | 7 | 1 | Protocol | The interface protocol (USB Org defined) |
| iInterface | 8 | 1 | Index | The name of the interface (or 0 if not provided) |
bInterfaceNumber is used by the host to indicate this interface when
sending messages, and the bAlternateSetting is a way to vary interfaces. Two
interfaces with the came bInterfaceNumber but different bAlternateSettings
can be switched between (like configurations, but) without resetting the
device.
Hopefully the rest of this descriptor is self-evident by now.
The next descriptor kind is endpoint descriptors:
| Field Name | Byte start | Byte length | Encoding | Meaning |
|---|---|---|---|---|
| bLength | 0 | 1 | Number | Size of the descriptor in bytes (7) |
| bDescriptorType | 1 | 1 | Constant | Endpoint Descriptor (0x05) |
| bEndpointAddress | 2 | 1 | Endpoint | Endpoint address (see below) |
| bmAttributes | 3 | 1 | Bitmap | Endpoint attributes (see below) |
| wMaxPacketSize | 4 | 2 | Number | Maximum packet size this endpoint can send/receive |
| bInterval | 6 | 1 | Number | Interval for polling endpoint (in frames) |
bEndpointAddress is a 4 bit endpoint number (so there're 16 endpoint
indices) and a bit to indicate IN vs. OUT. Bit 7 is the direction marker
and bits 3 to 0 are the endpoint number. This means there are 32 endpoints in
total, 16 in each direction, 2 of which are reserved (IN0 and OUT0) giving
30 endpoints available for interfaces to use in any given configuration. The
bmAttributes bitmap covers the transfer type of the endpoint (more below), and
the bInterval is an interval measured in frames (1ms for low or full speed,
125 s in high speed). bInterval is only valid for some endpoint types.
The final descriptor kind is for the strings which we've seen indices for
throughout the above. String descriptors have two forms:
| Field Name | Byte start | Byte length | Encoding | Meaning |
|---|---|---|---|---|
| bLength | 0 | 1 | Number | Size of the descriptor in bytes (variable) |
| bDescriptorType | 1 | 1 | Constant | String Descriptor (0x03) |
| wLangID[0] | 2 | 2 | Number | Language code zero (e.g. 0x0409 for en_US) |
| wLangID[n] | 4.. | 2 | Number | Language code n ... |
0) is that of a series of language IDs supported by
the device. The device may support any number of languages. When the host
requests a string descriptor, it will supply both the index of the string and
also the language id it desires (from the list available in string descriptor
zero). The host can tell how many language IDs are available simply by
dividing bLength by 2 and subtracting 1 for the two header bytes.
And for string descriptors of an index greater than zero:
| Field Name | Byte start | Byte length | Encoding | Meaning |
|---|---|---|---|---|
| bLength | 0 | 1 | Number | Size of the descriptor in bytes (variable) |
| bDescriptorType | 1 | 1 | Constant | String Descriptor (0x03) |
| bString | 2.. | .. | Unicode | The string, in "unicode" format |
bLength and bDescriptorType fields which can be checked and memory
allocated. Then a request for bLength bytes can be sent to retrieve the
entire string descriptor.
I've made several changes to the Weblate Docker container which are worth mentioning today.
First of all if you are still using nijel/weblate, you should switch to weblate/weblate. They both currently share same configuration, but it might happen that some future updates will go to the weblate owned container only.
Now back to the container changes. Since beginning we were using Django built in server. That's fine for development purposes, but it really doesn't work that well in production as it can handle only one request at time. Therefore we've switched to more robust approach using nginx + uwsgi + supervisor.
Thanks to this, the docker-compose no longer needs separate nginx server as everything is now sanely handled within the weblate container itself.
Next.