WEBVTT

00:00:00.000 --> 00:00:01.480
<v Brian Amos>This is The Amp Hour Podcast.

00:00:02.980 --> 00:00:05.760
<v Brian Amos>Released March 13th, 2022.

00:00:08.060 --> 00:00:09.720
<v Brian Amos>Episode 581.

00:00:11.780 --> 00:00:14.220
<v Brian Amos>Real-time operating systems with Brian Amos.

00:00:30.000 --> 00:00:33.600
<v Chris Gammell>Welcome to The Amp Hour. I'm Chris Gammell of Contextual Electronics.

00:00:34.100 --> 00:00:39.040
<v Chris Gammell>And this is Brian Amos, author of Hands-On RTOS with Microcontrollers.

00:00:39.460 --> 00:00:40.560
<v Brian Amos>Hey, Brian. How are you?

00:00:40.880 --> 00:00:41.960
<v Brian Amos>Doing well. How about you, Chris?

00:00:42.460 --> 00:00:46.900
<v Brian Amos>I'm good. I first heard about your book, I believe, from Philip from Embedded Artistry.

00:00:47.500 --> 00:00:53.180
<v Brian Amos>And then I read it, and I was getting into RTOS's, and it's a really good book.

00:00:53.180 --> 00:00:54.560
<v Brian Amos>So thanks for being on the show today.

00:00:54.660 --> 00:00:58.440
<v Brian Amos>I'm excited to ask you all the dumb questions that I had as I was reading the book.

00:00:58.440 --> 00:01:02.820
<v Chris Gammell>My pleasure. You're definitely in the target audience for the book.

00:01:03.100 --> 00:01:04.780
<v Brian Amos>People who are dumb with RTOS's? All right.

00:01:04.980 --> 00:01:05.980
<v Brian Amos>Yeah, that's right.

00:01:06.400 --> 00:01:14.120
<v Chris Gammell>No, hardware engineers with prior programming experience have a familiarity with hardware.

00:01:15.020 --> 00:01:16.220
<v Brian Amos>Yeah, yeah, yeah, yeah.

00:01:16.480 --> 00:01:18.560
<v Brian Amos>I mean, this all kind of started coming up when I was...

00:01:18.560 --> 00:01:25.460
<v Brian Amos>So I was doing some NRF52 projects, and I was kind of poking around the NRF5 SDK,

00:01:25.940 --> 00:01:27.860
<v Brian Amos>and there was a bunch of free RTOS stuff on there.

00:01:27.860 --> 00:01:33.640
<v Brian Amos>And I was thinking I could do some Bluetooth stuff using their binary blob,

00:01:33.840 --> 00:01:37.320
<v Brian Amos>but there was other examples using free RTOS, and a bunch of people had used free RTOS.

00:01:37.780 --> 00:01:41.960
<v Brian Amos>And so I started exploring it, and I think that kind of led me down the path towards this stuff.

00:01:42.040 --> 00:01:48.000
<v Brian Amos>And I remember I talked to Alvaro Prieto, who's one of the co-hosts of the Reverse Engineer podcast,

00:01:48.240 --> 00:01:50.540
<v Brian Amos>and he's a big free RTOS fan as well.

00:01:50.540 --> 00:01:52.460
<v Brian Amos>And I think he had also maybe mentioned the book.

00:01:52.680 --> 00:01:56.320
<v Brian Amos>But just kind of like as a starting point, people...

00:01:56.320 --> 00:01:59.040
<v Brian Amos>I was like, all right, I need to learn RTOS's.

00:01:59.760 --> 00:02:02.340
<v Brian Amos>And I was kind of just hunting around for info.

00:02:02.620 --> 00:02:04.400
<v Brian Amos>Is that a common thing that you see?

00:02:04.500 --> 00:02:07.760
<v Brian Amos>There's people just saying, today's the day I need to start learning RTOS's?

00:02:08.460 --> 00:02:11.320
<v Chris Gammell>I don't really get too much...

00:02:11.320 --> 00:02:15.000
<v Chris Gammell>People aren't coming to me saying, oh, how do I get started?

00:02:15.760 --> 00:02:16.700
<v Brian Amos>How do I RTOS?

00:02:17.000 --> 00:02:17.240
<v Chris Gammell>Yeah.

00:02:17.360 --> 00:02:18.140
<v Chris Gammell>How do I...

00:02:18.140 --> 00:02:20.040
<v Chris Gammell>How is this whole RTOS thing?

00:02:20.780 --> 00:02:25.160
<v Chris Gammell>Usually I wind up talking to people that have been programming for a while,

00:02:25.500 --> 00:02:30.880
<v Chris Gammell>and inevitably they don't really know what an RTOS is,

00:02:30.940 --> 00:02:34.480
<v Chris Gammell>or why they would want to use one.

00:02:34.480 --> 00:02:40.420
<v Chris Gammell>So it's not even like, oh, how do I get started in this?

00:02:40.480 --> 00:02:41.420
<v Chris Gammell>How do I dive in?

00:02:42.000 --> 00:02:47.260
<v Chris Gammell>It's more like, well, I have my C compiler, and what else do I need?

00:02:47.920 --> 00:02:48.020
<v Chris Gammell>Right?

00:02:48.480 --> 00:02:48.960
<v Chris Gammell>Yeah.

00:02:49.380 --> 00:02:51.640
<v Chris Gammell>There are lots of tools out there that can help you.

00:02:52.540 --> 00:02:52.980
<v Brian Amos>Yeah.

00:02:53.020 --> 00:02:56.140
<v Brian Amos>I think, I mean, for people that are thinking about an RTOS,

00:02:56.200 --> 00:02:59.980
<v Brian Amos>I feel like the first thing is like, well, would a state machine do what you're really needing?

00:02:59.980 --> 00:03:04.360
<v Brian Amos>It's like, if so, and it's really small, that might be the best option.

00:03:04.620 --> 00:03:08.120
<v Brian Amos>You know, it's like, but then I had been asking some people about like, oh, well,

00:03:08.120 --> 00:03:12.100
<v Brian Amos>should I just start, you know, start from the premise of like, just go straight to it.

00:03:12.120 --> 00:03:14.540
<v Brian Amos>I'm going to have a real-time operating system instead of a state machine.

00:03:15.060 --> 00:03:17.680
<v Brian Amos>And some people said, yeah, you know, that's how I prefer to do it.

00:03:18.160 --> 00:03:18.280
<v Chris Gammell>Yeah.

00:03:18.880 --> 00:03:25.560
<v Chris Gammell>It's funny because a lot of the projects that I've done, some of them are inherited, right?

00:03:25.560 --> 00:03:28.920
<v Chris Gammell>So you already have a code base and you need to add some features to it.

00:03:29.420 --> 00:03:34.120
<v Chris Gammell>And other times you have an idea of what you're going to be doing.

00:03:34.120 --> 00:03:35.920
<v Chris Gammell>And it's, it's more well-defined.

00:03:36.080 --> 00:03:38.740
<v Chris Gammell>You can kind of bound it a little bit better.

00:03:38.740 --> 00:03:46.560
<v Chris Gammell>And that, if you know ahead of time, minimum requirements and then desirements after,

00:03:46.560 --> 00:03:51.700
<v Chris Gammell>you know, that, that MVP is done, then you can usually get a pretty good idea.

00:03:52.100 --> 00:03:52.140
<v Chris Gammell>But.

00:03:52.620 --> 00:03:52.720
<v Brian Amos>Okay.

00:03:53.040 --> 00:03:53.640
<v Brian Amos>So, okay.

00:03:53.640 --> 00:03:57.560
<v Brian Amos>So say we got a greenfield project, not like a brown, I say brownfield for inherited,

00:03:57.720 --> 00:04:00.340
<v Brian Amos>already built greenfield for clean sheet of paper.

00:04:00.340 --> 00:04:00.860
<v Brian Amos>Yep.

00:04:01.040 --> 00:04:07.240
<v Brian Amos>What is, give us an example of a project that you've either seen or, or tell me about a

00:04:07.240 --> 00:04:07.500
<v Brian Amos>time.

00:04:07.680 --> 00:04:08.500
<v Brian Amos>It's like an interviewer.

00:04:08.700 --> 00:04:09.640
<v Brian Amos>Tell me about a time.

00:04:10.920 --> 00:04:14.720
<v Brian Amos>But like, what is a good example of like, yeah, you're probably going to want an RTOS

00:04:14.720 --> 00:04:16.740
<v Brian Amos>or maybe not.

00:04:17.140 --> 00:04:18.340
<v Brian Amos>You don't have to care about it.

00:04:18.540 --> 00:04:19.240
<v Brian Amos>Do you have those in your head?

00:04:19.780 --> 00:04:19.980
<v Chris Gammell>Yeah.

00:04:19.980 --> 00:04:25.780
<v Chris Gammell>So anything with, if you have a user interface, almost definitely because, you know, especially

00:04:25.780 --> 00:04:28.700
<v Chris Gammell>like a GUI and onboard GUI or something like that.

00:04:29.640 --> 00:04:34.060
<v Chris Gammell>Anything with extensive communications capability for sure.

00:04:34.920 --> 00:04:40.700
<v Chris Gammell>So network connectivity, USB, tons and tons of spy.

00:04:41.660 --> 00:04:41.900
<v Chris Gammell>You are.

00:04:42.140 --> 00:04:43.680
<v Brian Amos>Anything with a stack in the name.

00:04:43.680 --> 00:04:44.120
<v Brian Amos>Yeah.

00:04:45.060 --> 00:04:45.500
<v Chris Gammell>Yeah.

00:04:45.700 --> 00:04:51.700
<v Chris Gammell>Lots of, especially, especially like third party stacks that might be really bloated.

00:04:52.000 --> 00:04:58.700
<v Chris Gammell>You know, if you can wind up, if you can, you can use an RTOS to segment a lot of that,

00:04:59.400 --> 00:05:01.540
<v Chris Gammell>what I'm going to say, lower priority stuff.

00:05:01.540 --> 00:05:05.380
<v Chris Gammell>And then, you know, write really efficient event driven code.

00:05:05.400 --> 00:05:07.760
<v Chris Gammell>That's really, really close to the hardware.

00:05:08.060 --> 00:05:10.680
<v Chris Gammell>You know, we're talking ISRs, all that kind of stuff.

00:05:10.680 --> 00:05:11.240
<v Chris Gammell>Right.

00:05:11.360 --> 00:05:17.880
<v Chris Gammell>And so you push off all of the third party stuff, push it into its own task, give it

00:05:17.880 --> 00:05:18.960
<v Chris Gammell>a nice low priority.

00:05:19.220 --> 00:05:24.520
<v Chris Gammell>And then any of your higher priority things that deal more directly with time sensitive

00:05:24.520 --> 00:05:27.600
<v Chris Gammell>hardware, you kind of do that like under the hood, right?

00:05:28.220 --> 00:05:29.560
<v Chris Gammell>Actually below the RTOS.

00:05:29.780 --> 00:05:33.320
<v Chris Gammell>So you don't even have to interact with RTOS if you don't, unless you have a reason.

00:05:33.560 --> 00:05:38.300
<v Brian Amos>That's kind of confusing too, because low priority is, it's like a low priority.

00:05:38.360 --> 00:05:39.140
<v Brian Amos>It's like golf, right?

00:05:39.140 --> 00:05:40.940
<v Brian Amos>It's like, if you're bad at golf, you have a high score.

00:05:41.460 --> 00:05:46.100
<v Brian Amos>If you have low, if you have a low priority in an RTOS system, you have a high priority

00:05:46.100 --> 00:05:46.480
<v Brian Amos>score.

00:05:46.480 --> 00:05:47.000
<v Brian Amos>Isn't that right?

00:05:47.040 --> 00:05:48.140
<v Brian Amos>Or is that, I have that backwards?

00:05:48.280 --> 00:05:54.740
<v Chris Gammell>Well, that's like, so the cortex, I'm not talking about a cortex M ISR rankings here.

00:05:54.840 --> 00:05:56.520
<v Chris Gammell>I'm, I'm, I literally mean low priority.

00:05:56.520 --> 00:06:05.140
<v Chris Gammell>So if you've got something, let's say, all right, let's say that I have a, like a, a control

00:06:05.140 --> 00:06:05.820
<v Chris Gammell>system, right?

00:06:05.820 --> 00:06:10.940
<v Chris Gammell>So I have a closed loop control system where I'm reading sensor data and I want to control

00:06:10.940 --> 00:06:13.640
<v Chris Gammell>the position of, let's say a motor, right?

00:06:13.640 --> 00:06:20.340
<v Chris Gammell>So I'm going to read in data from a sensor and I'm going to control some sort of an actuator.

00:06:20.860 --> 00:06:21.260
<v Chris Gammell>Okay.

00:06:21.260 --> 00:06:23.540
<v Chris Gammell>And you have to do that in a tight loop.

00:06:23.860 --> 00:06:26.060
<v Chris Gammell>So we'll say that's high priority, right?

00:06:26.060 --> 00:06:30.900
<v Chris Gammell>Because that's like the main purpose of this system is to control this, this motor, right?

00:06:30.920 --> 00:06:32.020
<v Chris Gammell>It's a servo control system.

00:06:32.380 --> 00:06:39.280
<v Chris Gammell>And then let's say that you also have a front panel for changing the set point or whatever,

00:06:39.280 --> 00:06:39.780
<v Chris Gammell>right?

00:06:40.340 --> 00:06:42.300
<v Chris Gammell>Of this positioning system.

00:06:42.300 --> 00:06:48.200
<v Chris Gammell>So I'm going to argue that the front panel is a much, much lower priority because it's

00:06:48.200 --> 00:06:49.760
<v Chris Gammell>only dealing with user input.

00:06:50.080 --> 00:06:50.420
<v Brian Amos>Right.

00:06:50.660 --> 00:06:53.720
<v Chris Gammell>Than the actual positioning of the motor, right?

00:06:53.800 --> 00:06:58.520
<v Chris Gammell>So, you know, you, like UX guys are going to be screaming, you know, oh, I can't have

00:06:58.520 --> 00:06:58.940
<v Chris Gammell>glitchy UI.

00:06:58.940 --> 00:07:00.080
<v Brian Amos>We need it to be responsive.

00:07:00.440 --> 00:07:00.680
<v Chris Gammell>Yeah.

00:07:00.680 --> 00:07:00.800
<v Chris Gammell>Yeah.

00:07:01.360 --> 00:07:05.800
<v Chris Gammell>It's like, okay, well, you know, you can have your responsive UI and that's fine.

00:07:06.180 --> 00:07:09.680
<v Chris Gammell>But the position of this thing is really kind of the important.

00:07:09.680 --> 00:07:12.340
<v Chris Gammell>If we chop someone's finger off, we're going to, we're going to be in trouble.

00:07:12.840 --> 00:07:13.880
<v Chris Gammell>Yeah, exactly.

00:07:14.800 --> 00:07:22.080
<v Chris Gammell>So, so the, the nice part about if you have this, you know, crazy, let's say you've got

00:07:22.080 --> 00:07:26.960
<v Chris Gammell>animations on the UI, a whole bunch of unnecessary crap that's like standard these days, right?

00:07:26.960 --> 00:07:32.860
<v Chris Gammell>And expected, you can kind of, you, you push the priority of all that junk down and then,

00:07:32.860 --> 00:07:38.960
<v Chris Gammell>you know, you operate a higher priority for all the stuff that actually matters.

00:07:38.960 --> 00:07:40.960
<v Chris Gammell>So it's, it's great for prioritization.

00:07:41.740 --> 00:07:45.840
<v Chris Gammell>You know, it's, it's definitely not a magic bullet there by any means, but yeah.

00:07:46.200 --> 00:07:46.640
<v Chris Gammell>Yeah.

00:07:46.640 --> 00:07:47.780
<v Chris Gammell>So that's, that's one case.

00:07:47.780 --> 00:07:52.780
<v Chris Gammell>And, you know, let's say that this thing has also got some crazy IOT stack on it or whatever.

00:07:52.780 --> 00:07:58.100
<v Chris Gammell>And it's talking, talking, talking to the cloud or whatever, right?

00:07:58.180 --> 00:08:05.380
<v Chris Gammell>Some, some horribly, you know, bloated piece of software that has been written by, you know,

00:08:05.440 --> 00:08:10.060
<v Chris Gammell>an entire team and you bring that in, push that to a low priority too, right?

00:08:10.340 --> 00:08:12.920
<v Chris Gammell>And then, you know, it's just focus on the real time stuff.

00:08:12.920 --> 00:08:14.920
<v Brian Amos>You can talk to the network when I tell you, you can talk to the network.

00:08:15.640 --> 00:08:16.000
<v Brian Amos>Exactly.

00:08:16.220 --> 00:08:16.320
<v Brian Amos>Yeah.

00:08:16.540 --> 00:08:16.820
<v Chris Gammell>Yeah.

00:08:16.880 --> 00:08:19.540
<v Chris Gammell>And, you know, you want to do that stuff in the background when you have time, that's,

00:08:19.600 --> 00:08:20.720
<v Chris Gammell>that's perfectly okay.

00:08:20.720 --> 00:08:25.520
<v Chris Gammell>But let me just make sure that I actually do my primary function first.

00:08:25.900 --> 00:08:26.240
<v Chris Gammell>Yeah.

00:08:26.440 --> 00:08:26.700
<v Chris Gammell>Yep.

00:08:26.860 --> 00:08:30.360
<v Chris Gammell>So anytime multitasking is important and you have a bunch of little.

00:08:30.780 --> 00:08:31.020
<v Brian Amos>Yeah.

00:08:31.100 --> 00:08:35.640
<v Brian Amos>So, so the multitasking, a lot of different kind of once in a while things happening.

00:08:35.640 --> 00:08:41.200
<v Brian Amos>I, I, I kind of, I remember coming at this problem from like thinking, thinking about

00:08:41.200 --> 00:08:45.580
<v Brian Amos>it from more of a, like an embedded Linux perspective and thinking like, I wouldn't want

00:08:45.580 --> 00:08:52.820
<v Brian Amos>something trying to get an update on a webpage while I'm waiting on, you know, data coming

00:08:52.820 --> 00:08:55.060
<v Brian Amos>back from like a spy sensor or something like that.

00:08:55.140 --> 00:08:55.480
<v Brian Amos>Exactly.

00:08:55.480 --> 00:08:57.400
<v Brian Amos>And that would be bad.

00:08:57.400 --> 00:09:02.660
<v Brian Amos>And, and a full, full operating system like Linux does that sort of thing at a different

00:09:02.660 --> 00:09:02.960
<v Brian Amos>level.

00:09:02.960 --> 00:09:08.380
<v Brian Amos>So could you differentiate then for people real time operating system from a full operating

00:09:08.380 --> 00:09:08.820
<v Brian Amos>system?

00:09:09.240 --> 00:09:09.340
<v Chris Gammell>Yeah.

00:09:09.440 --> 00:09:12.900
<v Chris Gammell>So, so the book was based off of a free RTOS.

00:09:12.900 --> 00:09:18.060
<v Chris Gammell>I mean, a lot of the microcontroller targeted RTOS is are very, very similar, but you know,

00:09:18.100 --> 00:09:23.940
<v Chris Gammell>with, with free or free RTOS is really just, it's pretty much just a scheduler and like

00:09:23.940 --> 00:09:29.500
<v Chris Gammell>some really basic things like, you know, cues, semaphores, task notifications, that kind of

00:09:29.500 --> 00:09:29.700
<v Chris Gammell>stuff.

00:09:29.780 --> 00:09:34.060
<v Chris Gammell>So there isn't, you don't have any libraries, you know, there's, there isn't a whole lot of

00:09:34.060 --> 00:09:36.660
<v Chris Gammell>stuff now that Amazon acquired them.

00:09:36.940 --> 00:09:41.420
<v Chris Gammell>They're starting to add a bunch of that stuff, but at its core, it's really just a scheduling

00:09:41.420 --> 00:09:48.160
<v Chris Gammell>kernel as opposed to, as opposed to Linux, which is of course, you know, full blown operating

00:09:48.160 --> 00:09:52.380
<v Chris Gammell>system and you can bring in libraries and drivers and all that kind of stuff.

00:09:52.480 --> 00:09:54.420
<v Chris Gammell>You don't really get any of that stuff.

00:09:54.920 --> 00:09:57.160
<v Chris Gammell>Different RTOS is you can, you can purchase them.

00:09:57.560 --> 00:10:00.020
<v Chris Gammell>You can purchase modules sometimes, right?

00:10:00.080 --> 00:10:04.620
<v Chris Gammell>Depending on the vendor and that sort of a thing, but it's, it's really just super pared

00:10:04.620 --> 00:10:05.000
<v Chris Gammell>down.

00:10:05.000 --> 00:10:13.040
<v Chris Gammell>And what it, what it's really, really good at is bounding things based off of time.

00:10:13.040 --> 00:10:18.940
<v Chris Gammell>So if you say, oh, in your example with the, you know, waiting on data coming back from a

00:10:18.940 --> 00:10:21.260
<v Chris Gammell>spy sensor while you're trying to load a webpage, right?

00:10:21.960 --> 00:10:28.060
<v Chris Gammell>The data coming back from that spy sensor, you could actually bound that and say, Hey, I

00:10:28.060 --> 00:10:32.760
<v Chris Gammell>expect data back from the sensor within 10 milliseconds.

00:10:33.720 --> 00:10:40.700
<v Chris Gammell>And if it doesn't come back, if it doesn't complete in this amount of time, you know, or if I can't,

00:10:40.700 --> 00:10:48.600
<v Chris Gammell>if I can't acquire a mutex or a semifor or whatever you're using to access this peripheral in X number

00:10:48.600 --> 00:10:54.360
<v Chris Gammell>of milliseconds, then bail out and, you know, do something right.

00:10:54.360 --> 00:11:01.000
<v Chris Gammell>So all those kinds of timeouts are built into pretty much all the calls, you know, it, and

00:11:01.000 --> 00:11:07.640
<v Chris Gammell>there's always, you're always thinking about, okay, after, after this thing goes wrong and

00:11:07.640 --> 00:11:09.560
<v Chris Gammell>there's no sensor on the other end, what happens?

00:11:09.560 --> 00:11:09.840
<v Chris Gammell>Right.

00:11:09.860 --> 00:11:17.960
<v Chris Gammell>So you don't get into, and you can put in infinite delays if you really want to, it lets you,

00:11:18.140 --> 00:11:22.380
<v Chris Gammell>but you know, you're always thinking about what happens if something goes wrong.

00:11:22.380 --> 00:11:26.560
<v Chris Gammell>So it kind of gets you into that mindset and that's something pretty different as well.

00:11:27.140 --> 00:11:30.460
<v Chris Gammell>I mean, you know, for, for systems programming, I suppose you have exceptions and that kind

00:11:30.460 --> 00:11:31.060
<v Chris Gammell>of stuff, but.

00:11:31.860 --> 00:11:32.220
<v Brian Amos>Yeah.

00:11:32.840 --> 00:11:40.480
<v Brian Amos>So, so the, the thing that I always hear about with like OS versus R2S is something about memory

00:11:40.480 --> 00:11:41.640
<v Brian Amos>management is one thing.

00:11:41.940 --> 00:11:45.180
<v Brian Amos>Is that kind of the, or is it just more of the build out as well?

00:11:45.180 --> 00:11:45.620
<v Brian Amos>Yeah.

00:11:45.620 --> 00:11:49.000
<v Brian Amos>Cause like the, the other thing, my other reference point here is that I've been doing

00:11:49.000 --> 00:11:50.780
<v Brian Amos>a lot of Zephyr stuff poorly.

00:11:51.100 --> 00:11:53.380
<v Brian Amos>I'm learning a lot of Zephyr stuff, I suppose I should say.

00:11:54.420 --> 00:11:58.520
<v Brian Amos>And, and that's kind of like, it's not just the kernel.

00:11:58.620 --> 00:12:02.740
<v Brian Amos>It's not just, you know, there's like other stuff kind of already there and monologuing

00:12:02.740 --> 00:12:03.380
<v Brian Amos>and built in.

00:12:03.820 --> 00:12:06.980
<v Brian Amos>And it's, so it's, it's more like starting from the middle and saying like, okay, you've

00:12:06.980 --> 00:12:10.420
<v Brian Amos>already got a lot of stuff in this huge package and you can pare it down.

00:12:10.460 --> 00:12:12.180
<v Brian Amos>But most of it, you're what you're getting.

00:12:12.760 --> 00:12:14.660
<v Brian Amos>You kind of get it all there first.

00:12:14.800 --> 00:12:18.960
<v Brian Amos>Whereas like you're saying with FreeR Toss, it's kind of like, when you start from the

00:12:18.960 --> 00:12:23.260
<v Brian Amos>bottom and you build up, you can bolt stuff on and, and put things together, but you start

00:12:23.260 --> 00:12:25.620
<v Brian Amos>with a, the assumption that there's not much there.

00:12:25.620 --> 00:12:28.000
<v Brian Amos>And then I think Linux side is like, yeah.

00:12:28.120 --> 00:12:33.940
<v Chris Gammell>And as far as memory management goes, like you can do as much or as little as you want.

00:12:34.180 --> 00:12:40.560
<v Chris Gammell>So there are ways of creating entire projects and it's not just FreeR Toss, but you know,

00:12:40.580 --> 00:12:44.920
<v Chris Gammell>with a lot of R Tosses that are purely statically allocated.

00:12:45.140 --> 00:12:47.700
<v Chris Gammell>So there is no, there is no heap, right?

00:12:48.400 --> 00:12:48.840
<v Brian Amos>Yeah.

00:12:49.140 --> 00:12:50.400
<v Chris Gammell>So there is no penalty.

00:12:50.540 --> 00:12:51.400
<v Chris Gammell>There is no Malik.

00:12:51.500 --> 00:12:55.360
<v Chris Gammell>There is no new, you know, those kinds of projects exist.

00:12:55.620 --> 00:13:03.000
<v Chris Gammell>And you can get really, really good at predicting how long things are going to take when you're

00:13:03.000 --> 00:13:07.300
<v Chris Gammell>not using a heap because it's just machine cycles at that point.

00:13:07.380 --> 00:13:11.140
<v Chris Gammell>You're not searching for a spot to put this variable in memory, right?

00:13:11.660 --> 00:13:19.620
<v Chris Gammell>Uh, uh, and then, you know, even if you use the FreeR Toss heap, if you prescribe to the

00:13:19.620 --> 00:13:23.540
<v Chris Gammell>notion that you create tasks and then they just run forever, like their own little state

00:13:23.540 --> 00:13:26.100
<v Chris Gammell>machine, each task is basically a state machine, right?

00:13:26.480 --> 00:13:32.880
<v Chris Gammell>So if you, let's say you create five tasks and you want to have the ability to do dynamic

00:13:32.880 --> 00:13:34.320
<v Chris Gammell>allocation, you can use the heap.

00:13:34.720 --> 00:13:39.820
<v Chris Gammell>But the only time that you're, so you would set up a stack for each one of those tasks.

00:13:39.820 --> 00:13:44.720
<v Chris Gammell>And at the beginning, like, you know, right at the beginning of main before you start the

00:13:44.720 --> 00:13:47.180
<v Chris Gammell>scheduler and you don't have to touch those.

00:13:47.340 --> 00:13:52.560
<v Chris Gammell>So as long as you go out and you acquire the memory that you need, you have the memory, there

00:13:52.560 --> 00:13:56.600
<v Chris Gammell>is no more dynamic allocation and you're, you're good to go.

00:13:57.140 --> 00:13:57.220
<v Brian Amos>Yeah.

00:13:57.340 --> 00:13:58.380
<v Brian Amos>So you get what you get then, right?

00:13:58.400 --> 00:13:59.620
<v Brian Amos>You're just, you're just doing that.

00:13:59.960 --> 00:14:01.240
<v Brian Amos>You're just using the memory you have at the beginning.

00:14:01.240 --> 00:14:01.720
<v Chris Gammell>Yeah.

00:14:01.900 --> 00:14:02.480
<v Chris Gammell>So, right.

00:14:02.540 --> 00:14:08.080
<v Chris Gammell>If, if you're like, okay, well, this is a pretty, you know, this is a very small task.

00:14:08.200 --> 00:14:14.000
<v Chris Gammell>It can probably get away with 512 bytes of stack space or whatever, you know, then the stack

00:14:14.000 --> 00:14:17.720
<v Chris Gammell>for that task is set to 512 bytes.

00:14:17.920 --> 00:14:20.980
<v Chris Gammell>You never have to ask for more and right.

00:14:21.040 --> 00:14:21.940
<v Chris Gammell>That, that, that's it.

00:14:22.220 --> 00:14:25.260
<v Chris Gammell>And that, that task will do whatever it needs to do.

00:14:26.140 --> 00:14:29.640
<v Chris Gammell>And as long as you never go above 512 bytes, you're golden.

00:14:29.640 --> 00:14:30.080
<v Chris Gammell>Right.

00:14:31.280 --> 00:14:31.480
<v Chris Gammell>Right.

00:14:31.520 --> 00:14:36.160
<v Chris Gammell>Just like overrunning a raise, you know, bad things can and do happen.

00:14:36.800 --> 00:14:37.100
<v Chris Gammell>Yeah.

00:14:37.280 --> 00:14:37.520
<v Chris Gammell>Yeah.

00:14:37.980 --> 00:14:38.360
<v Chris Gammell>Yeah.

00:14:38.420 --> 00:14:43.080
<v Chris Gammell>But you know, it, it has some hooks in there to detect that kind of stuff as well.

00:14:43.180 --> 00:14:43.580
<v Chris Gammell>Got it.

00:14:44.080 --> 00:14:48.320
<v Brian Amos>So like the, the one, the thing I want to kind of offset there is like my, like I said, my

00:14:48.320 --> 00:14:49.280
<v Brian Amos>reference point is kind of Zephyr.

00:14:49.360 --> 00:14:50.940
<v Brian Amos>It's kind of like in the middle somewhere.

00:14:51.580 --> 00:14:54.980
<v Brian Amos>Free our toss and other kind of, and especially like bespoke our tosses.

00:14:54.980 --> 00:14:56.860
<v Brian Amos>Cause you talk about that in the book a little bit as well.

00:14:56.860 --> 00:15:00.220
<v Brian Amos>And that's kind of bottom up, you're kind of building each thing up.

00:15:00.340 --> 00:15:04.920
<v Brian Amos>And then when Jay Carlson was on the show talking about Linux embedded Linux development,

00:15:05.020 --> 00:15:09.000
<v Brian Amos>it's one thing he talked about was like, well, you're going to end up reading a lot of code,

00:15:09.040 --> 00:15:10.120
<v Brian Amos>but not writing a lot of code.

00:15:10.220 --> 00:15:14.020
<v Brian Amos>So it seems like the free our toss, you are writing a lot of code, but you are crafting

00:15:14.020 --> 00:15:15.240
<v Brian Amos>it how you want it to be.

00:15:15.260 --> 00:15:17.060
<v Brian Amos>So it is that bottom up methodology.

00:15:17.260 --> 00:15:18.040
<v Chris Gammell>Yeah, very much so.

00:15:18.040 --> 00:15:21.300
<v Chris Gammell>And you know, it, it's API is pretty minimal.

00:15:21.660 --> 00:15:27.480
<v Chris Gammell>So you're not really, I mean, if you're bringing in the exception of course is as soon as you

00:15:27.480 --> 00:15:30.520
<v Chris Gammell>start bringing in third-party libraries, you're reading a ton of code, right.

00:15:30.820 --> 00:15:33.140
<v Chris Gammell>Or maybe documentation or whatever.

00:15:33.660 --> 00:15:33.760
<v Brian Amos>Right.

00:15:34.320 --> 00:15:34.760
<v Brian Amos>Yeah.

00:15:34.760 --> 00:15:39.520
<v Brian Amos>You want to know how you can interact with their APIs and what are all the gotchas from

00:15:39.520 --> 00:15:42.980
<v Brian Amos>that sort of thing and what you might want to draw out of them.

00:15:43.160 --> 00:15:43.280
<v Brian Amos>Right.

00:15:43.400 --> 00:15:44.400
<v Chris Gammell>Yes, exactly.

00:15:44.620 --> 00:15:44.860
<v Chris Gammell>Yeah.

00:15:44.860 --> 00:15:45.300
<v Chris Gammell>Yeah.

00:15:46.080 --> 00:15:50.120
<v Brian Amos>So one thing I really liked about your book was because it is that bottom up methodology,

00:15:50.520 --> 00:15:57.360
<v Brian Amos>I feel like most books start a little bit too, most of the free, most of the artos books

00:15:57.360 --> 00:16:02.540
<v Brian Amos>that I've done, they immediately want to talk about just like only semaphores and only mute.

00:16:02.600 --> 00:16:06.500
<v Brian Amos>Like I remember John Labros's book about Micrium and Micro-COS too.

00:16:06.800 --> 00:16:10.840
<v Brian Amos>Very good book, very good reference, but man, it just wants to talk about mutexes.

00:16:10.940 --> 00:16:13.700
<v Brian Amos>And I'm just like, I don't, I don't know what the hell you're talking about right now.

00:16:13.700 --> 00:16:13.880
<v Chris Gammell>Yep.

00:16:13.880 --> 00:16:14.320
<v Chris Gammell>Yeah.

00:16:14.420 --> 00:16:18.940
<v Chris Gammell>That's why all the, all the diagrams were at the beginning with, without any code around

00:16:18.940 --> 00:16:21.100
<v Chris Gammell>them, like little, little flags.

00:16:21.480 --> 00:16:22.000
<v Chris Gammell>Here's a semaphore.

00:16:22.000 --> 00:16:22.660
<v Chris Gammell>That's really useful.

00:16:23.300 --> 00:16:23.480
<v Chris Gammell>Yeah.

00:16:23.640 --> 00:16:23.860
<v Chris Gammell>Yeah.

00:16:23.860 --> 00:16:27.980
<v Chris Gammell>That's because the first time that I used an artos, I, I drew out all that crap.

00:16:28.500 --> 00:16:28.900
<v Chris Gammell>Yeah.

00:16:28.960 --> 00:16:29.460
<v Chris Gammell>That's great.

00:16:29.580 --> 00:16:31.240
<v Chris Gammell>I haven't seen this stuff since school.

00:16:31.380 --> 00:16:32.460
<v Chris Gammell>I've got to, yeah.

00:16:32.520 --> 00:16:34.500
<v Chris Gammell>I've got to go back and get a refresher here.

00:16:34.960 --> 00:16:38.980
<v Brian Amos>And I think that's super important, you know, like to be able to do that sort of thing.

00:16:38.980 --> 00:16:44.640
<v Brian Amos>And I guess one of the things that I didn't realize because I got so kind of stuck on that

00:16:44.640 --> 00:16:49.460
<v Brian Amos>other stuff is, you know, I'm probably going to say this wrong now, but like the idea of

00:16:49.460 --> 00:16:55.420
<v Brian Amos>an artos having the segmented memory, like you said, that 512 bytes, it's kind of, it's

00:16:55.420 --> 00:16:58.740
<v Brian Amos>segmented, but then there it's like, it's doing its own thing.

00:16:58.880 --> 00:17:00.380
<v Brian Amos>The task, how does it say this?

00:17:00.380 --> 00:17:05.320
<v Brian Amos>It's like, you have these side-by-side neighbors or like apartments of memory, right?

00:17:05.480 --> 00:17:09.520
<v Brian Amos>And they're like side-by-side and they're living next to one another, but, but they are

00:17:09.520 --> 00:17:11.820
<v Brian Amos>the stacks that's, that live next to each other as well.

00:17:11.820 --> 00:17:12.100
<v Brian Amos>Right.

00:17:12.100 --> 00:17:14.680
<v Brian Amos>They're like, they act like a stack, but they're all.

00:17:14.820 --> 00:17:15.880
<v Chris Gammell>Well, they are, they are a stack.

00:17:15.980 --> 00:17:19.460
<v Chris Gammell>Each, each, each task has its own stack.

00:17:19.460 --> 00:17:19.760
<v Chris Gammell>Right.

00:17:19.800 --> 00:17:21.780
<v Chris Gammell>And that stack is only used by the task.

00:17:22.200 --> 00:17:23.480
<v Chris Gammell>And then you also have.

00:17:23.520 --> 00:17:23.500
<v Speaker ?>Yeah.

00:17:23.500 --> 00:17:24.500
<v Brian Amos>That was completely new knowledge to me.

00:17:24.560 --> 00:17:27.620
<v Brian Amos>Like I, I, I did not understand that at all about it prior to your book.

00:17:27.620 --> 00:17:30.180
<v Brian Amos>So that, that alone was the price of admission for me.

00:17:30.180 --> 00:17:31.600
<v Brian Amos>That was really worth it.

00:17:31.680 --> 00:17:32.080
<v Brian Amos>That was awesome.

00:17:32.220 --> 00:17:32.340
<v Brian Amos>Good.

00:17:32.680 --> 00:17:32.980
<v Chris Gammell>Yeah.

00:17:33.020 --> 00:17:36.920
<v Chris Gammell>And then, you know, there's, there's inner task communication between the tasks.

00:17:37.180 --> 00:17:37.440
<v Chris Gammell>Right.

00:17:38.040 --> 00:17:43.660
<v Chris Gammell>And that's, that's where you get things like, you know, okay, well I can have a queue and

00:17:43.660 --> 00:17:47.560
<v Chris Gammell>that queue, you know, let's, let's say that's a, that's a global, right.

00:17:47.560 --> 00:17:49.920
<v Chris Gammell>It doesn't live on either of the two stacks.

00:17:49.920 --> 00:17:51.420
<v Chris Gammell>It's effectively a global variable.

00:17:51.880 --> 00:17:56.840
<v Brian Amos>That's, you know, can we, can we make like a Sesame street style analogy here or something

00:17:56.840 --> 00:17:58.080
<v Brian Amos>that would be very useful for me?

00:17:58.080 --> 00:17:58.520
<v Brian Amos>Yeah.

00:17:59.420 --> 00:18:03.820
<v Brian Amos>We're like a queue is like, um, you know, there's like mailboxes and queues would be

00:18:03.820 --> 00:18:07.140
<v Brian Amos>like, I don't know, like a water slide between them or something.

00:18:07.500 --> 00:18:07.780
<v Chris Gammell>Yeah.

00:18:07.820 --> 00:18:08.060
<v Chris Gammell>Yeah.

00:18:08.060 --> 00:18:08.120
<v Chris Gammell>Yeah.

00:18:08.120 --> 00:18:10.960
<v Chris Gammell>And, uh, I think the, I have to go.

00:18:12.080 --> 00:18:12.940
<v Chris Gammell>Let's see.

00:18:13.340 --> 00:18:19.600
<v Chris Gammell>Understanding our test has, if you, if there are actually some really simple diagrams that

00:18:19.600 --> 00:18:21.000
<v Chris Gammell>explain this stuff at the beginning.

00:18:21.000 --> 00:18:21.760
<v Chris Gammell>Great.

00:18:21.760 --> 00:18:25.640
<v Brian Amos>Uh, and I have, I have the same PDF that Brian has opened.

00:18:25.640 --> 00:18:30.480
<v Brian Amos>So we can, we'll, we'll be able to say, we'll try and back back date it to where the chapter

00:18:30.480 --> 00:18:33.880
<v Brian Amos>and stuff like that, but we'll probably talk about page numbers here from the PDF.

00:18:33.880 --> 00:18:36.740
<v Brian Amos>So if you're on my Kindle version is very different.

00:18:36.820 --> 00:18:37.880
<v Brian Amos>So that's why we're looking at the PDF.

00:18:38.360 --> 00:18:38.520
<v Chris Gammell>Yeah.

00:18:38.600 --> 00:18:43.040
<v Chris Gammell>So if you look at the, the, the page numbers on the bottom of each page on that PDF are

00:18:43.040 --> 00:18:45.400
<v Chris Gammell>actually like the same page numbers as the book.

00:18:45.480 --> 00:18:47.540
<v Chris Gammell>The book is just like a printed version.

00:18:47.580 --> 00:18:47.740
<v Chris Gammell>Oh, great.

00:18:47.900 --> 00:18:49.840
<v Brian Amos>Oh, like the, you mean like the paper book?

00:18:50.060 --> 00:18:50.460
<v Brian Amos>Yeah.

00:18:50.520 --> 00:18:50.660
<v Brian Amos>Yeah.

00:18:50.660 --> 00:18:52.480
<v Chris Gammell>Dead tree, the dead tree thing.

00:18:53.580 --> 00:18:53.980
<v Brian Amos>Yeah.

00:18:54.060 --> 00:18:54.460
<v Brian Amos>No, I don't.

00:18:54.600 --> 00:18:54.800
<v Brian Amos>Yeah.

00:18:55.460 --> 00:18:57.500
<v Brian Amos>And I'm a Kindle guy personally.

00:18:58.160 --> 00:18:58.440
<v Chris Gammell>Yeah.

00:18:58.540 --> 00:19:01.520
<v Chris Gammell>There were quite a few complaints about the Kindle version.

00:19:02.580 --> 00:19:03.180
<v Chris Gammell>Oh yeah.

00:19:03.480 --> 00:19:07.120
<v Chris Gammell>Well, the publisher decided it was a good idea not to put chapter numbers.

00:19:08.100 --> 00:19:08.380
<v Chris Gammell>Yeah.

00:19:08.600 --> 00:19:10.460
<v Chris Gammell>There's no, there are no chapter numbers anywhere.

00:19:10.660 --> 00:19:11.100
<v Chris Gammell>It's crazy.

00:19:11.240 --> 00:19:11.380
<v Chris Gammell>Yep.

00:19:13.460 --> 00:19:13.860
<v Chris Gammell>Details.

00:19:14.320 --> 00:19:14.580
<v Chris Gammell>Yeah.

00:19:14.580 --> 00:19:14.880
<v Brian Amos>Details.

00:19:15.760 --> 00:19:15.980
<v Chris Gammell>Yeah.

00:19:16.060 --> 00:19:17.000
<v Chris Gammell>So, yeah.

00:19:17.080 --> 00:19:18.520
<v Chris Gammell>So, um, let's see.

00:19:19.520 --> 00:19:19.760
<v Chris Gammell>Yeah.

00:19:19.760 --> 00:19:21.840
<v Chris Gammell>So in chapter three, right.

00:19:21.900 --> 00:19:25.240
<v Chris Gammell>You have, you have these cues and there are some super, super simple.

00:19:25.420 --> 00:19:26.660
<v Chris Gammell>They're just, they're just boxes.

00:19:26.660 --> 00:19:30.540
<v Chris Gammell>If you have a, you have a cue of length four, right?

00:19:30.980 --> 00:19:36.820
<v Chris Gammell>You can think of that as four bins and you put something into the bin and then when you

00:19:36.820 --> 00:19:38.820
<v Chris Gammell>take it out the other end, that's, that's it.

00:19:38.900 --> 00:19:40.680
<v Chris Gammell>It's just like a conveyor belt, right?

00:19:40.920 --> 00:19:42.240
<v Chris Gammell>If you want to think of it that way.

00:19:42.380 --> 00:19:42.600
<v Chris Gammell>Yeah.

00:19:42.860 --> 00:19:43.100
<v Chris Gammell>Yeah.

00:19:43.520 --> 00:19:47.800
<v Brian Amos>Or how about if we, if we had two, two tiny fiefdoms of memory, then it would be like

00:19:47.800 --> 00:19:50.060
<v Brian Amos>the security checkpoint between the two, right?

00:19:50.060 --> 00:19:51.340
<v Brian Amos>Cause you'd get in line to check.

00:19:51.640 --> 00:19:51.700
<v Brian Amos>Yeah.

00:19:51.700 --> 00:19:51.920
<v Brian Amos>Yeah.

00:19:51.920 --> 00:19:52.080
<v Brian Amos>Exactly.

00:19:52.240 --> 00:19:52.580
<v Brian Amos>Right.

00:19:52.900 --> 00:19:53.120
<v Chris Gammell>Yeah.

00:19:53.120 --> 00:19:58.780
<v Chris Gammell>And then those, the two guards that are, you know, staring at each other through the

00:19:58.780 --> 00:20:03.860
<v Chris Gammell>two fiefdoms, they're, they're making sure that one task doesn't step on the data of

00:20:03.860 --> 00:20:04.780
<v Chris Gammell>another task, right?

00:20:04.840 --> 00:20:08.140
<v Brian Amos>So they're guarding between, if you want to go with that.

00:20:08.140 --> 00:20:10.640
<v Brian Amos>We're building, we're building a world here as we speak folks.

00:20:11.860 --> 00:20:13.880
<v Brian Amos>We moved away from Sesame Street pretty fast.

00:20:13.940 --> 00:20:15.780
<v Brian Amos>I'm pretty sure Sesame Street doesn't have guards.

00:20:15.900 --> 00:20:20.540
<v Brian Amos>You know, it's not like, uh, you know, the count being like one, one refugee coming

00:20:20.540 --> 00:20:21.760
<v Brian Amos>from one place to another.

00:20:22.400 --> 00:20:24.760
<v Chris Gammell>I mean, you need Oscar the Grouch in there too.

00:20:25.200 --> 00:20:25.520
<v Brian Amos>Yeah.

00:20:25.640 --> 00:20:25.760
<v Chris Gammell>Yeah.

00:20:25.820 --> 00:20:26.400
<v Chris Gammell>He would definitely be.

00:20:26.460 --> 00:20:26.500
<v Chris Gammell>Yeah.

00:20:26.500 --> 00:20:27.320
<v Chris Gammell>He's a trash collector.

00:20:27.380 --> 00:20:28.160
<v Chris Gammell>Totally be in there.

00:20:28.460 --> 00:20:32.820
<v Chris Gammell>He could be like taking care of, uh, counting semaphores and then.

00:20:33.220 --> 00:20:33.440
<v Chris Gammell>Yeah.

00:20:33.540 --> 00:20:33.760
<v Chris Gammell>Yeah.

00:20:33.760 --> 00:20:34.820
<v Chris Gammell>He'd be like the tick, right?

00:20:34.880 --> 00:20:38.500
<v Chris Gammell>I mean, he'd be like, uh, I think that's Oscar the Grouch should be like config assert.

00:20:39.120 --> 00:20:44.540
<v Chris Gammell>So in free, in free RTOS, there's a, whenever you do something wrong, like there's, there's

00:20:44.540 --> 00:20:47.420
<v Chris Gammell>all the, there's this notion of ISR safe functions.

00:20:47.420 --> 00:20:47.820
<v Chris Gammell>Right.

00:20:48.060 --> 00:20:54.120
<v Chris Gammell>And if you call a, if you, if let's say you try to add to a queue with like the normal

00:20:54.120 --> 00:20:58.060
<v Chris Gammell>API from inside of an ISR, then you get a config assert.

00:20:58.180 --> 00:21:00.060
<v Chris Gammell>So it's just, it's an assert that fails.

00:21:00.060 --> 00:21:03.220
<v Chris Gammell>And it's like, Whoa, this is within an interrupt context.

00:21:03.600 --> 00:21:04.560
<v Chris Gammell>So that's like, that could be awesome.

00:21:04.840 --> 00:21:04.960
<v Chris Gammell>Grouchy.

00:21:05.440 --> 00:21:05.680
<v Chris Gammell>Yeah.

00:21:05.680 --> 00:21:06.560
<v Chris Gammell>It's totally grouchy.

00:21:06.660 --> 00:21:06.800
<v Chris Gammell>That's good.

00:21:07.380 --> 00:21:07.520
<v Chris Gammell>Yeah.

00:21:08.320 --> 00:21:08.720
<v Chris Gammell>Okay.

00:21:09.240 --> 00:21:11.140
<v Brian Amos>So that's how you get from one task to another.

00:21:11.200 --> 00:21:12.480
<v Brian Amos>And so the task is kind of like the.

00:21:12.520 --> 00:21:13.220
<v Brian Amos>That's one of the ways.

00:21:13.300 --> 00:21:15.620
<v Brian Amos>Is that like the smallest block of memory?

00:21:15.620 --> 00:21:16.060
<v Brian Amos>Yeah.

00:21:16.060 --> 00:21:16.460
<v Chris Gammell>Yeah.

00:21:16.520 --> 00:21:21.100
<v Chris Gammell>Well, I mean, you know, you have semaphores, which are very, very tiny.

00:21:22.200 --> 00:21:28.480
<v Chris Gammell>I imagine in free RTOS, they kind of implement everything under the hood as a, as a queue, which

00:21:28.480 --> 00:21:35.800
<v Chris Gammell>is interesting from a, I think it saves, it saves ROM space, but you know, there are some

00:21:35.800 --> 00:21:39.260
<v Chris Gammell>people complain that there are faster ways of doing that, but yeah.

00:21:39.260 --> 00:21:43.820
<v Chris Gammell>So, I mean, you can have a queue of length one, you can have a binary semaphore, right?

00:21:43.860 --> 00:21:49.120
<v Chris Gammell>But the only, the only time that you're really creating these things that are running in

00:21:49.120 --> 00:21:52.100
<v Chris Gammell>concurrently or when you're creating a task.

00:21:52.760 --> 00:21:53.160
<v Speaker ?>Hmm.

00:21:53.680 --> 00:21:54.040
<v Brian Amos>Yeah.

00:21:54.080 --> 00:21:54.240
<v Brian Amos>Okay.

00:21:54.240 --> 00:21:59.340
<v Brian Amos>So now we have, so say we have a system with, maybe we should make up a fake example here.

00:21:59.560 --> 00:21:59.800
<v Chris Gammell>Yeah.

00:21:59.800 --> 00:22:02.240
<v Brian Amos>So we have a task that's.

00:22:02.300 --> 00:22:03.400
<v Chris Gammell>What's your system doing?

00:22:03.860 --> 00:22:04.900
<v Chris Gammell>What do you, what do you want your system?

00:22:04.900 --> 00:22:07.220
<v Brian Amos>Let's say, let's, let's call it a, um, how about a ventilator, right?

00:22:07.220 --> 00:22:08.700
<v Brian Amos>There's all that open ventilator stuff.

00:22:08.800 --> 00:22:11.500
<v Brian Amos>So it's like, there's a task that's measuring air pressure.

00:22:11.500 --> 00:22:13.280
<v Brian Amos>There's a task that's actuating pump.

00:22:13.460 --> 00:22:17.200
<v Brian Amos>There's a task that's updating a screen about the status of the pump.

00:22:17.400 --> 00:22:17.760
<v Brian Amos>Yep.

00:22:17.900 --> 00:22:22.520
<v Brian Amos>And there's a task that's reporting it to the internet or something like that.

00:22:22.520 --> 00:22:25.120
<v Brian Amos>Even though that would be a huge task, we're just going to, we're going to make it a

00:22:25.120 --> 00:22:25.760
<v Brian Amos>magic task.

00:22:25.760 --> 00:22:26.180
<v Brian Amos>How about that?

00:22:26.180 --> 00:22:26.380
<v Brian Amos>Sure.

00:22:26.640 --> 00:22:26.760
<v Chris Gammell>Yeah.

00:22:27.720 --> 00:22:27.960
<v Chris Gammell>Yeah.

00:22:28.040 --> 00:22:35.540
<v Chris Gammell>So, you know, you would have, you're probably going to have, I would say like a task that's

00:22:35.540 --> 00:22:42.140
<v Chris Gammell>taking care of reading the life, life critical kind of stuff.

00:22:42.140 --> 00:22:42.460
<v Chris Gammell>Right.

00:22:42.500 --> 00:22:44.880
<v Chris Gammell>So that gets the highest priority in the system.

00:22:45.300 --> 00:22:51.900
<v Chris Gammell>So if it has any work to do at all, then it will run no matter what.

00:22:51.900 --> 00:22:52.380
<v Chris Gammell>Right.

00:22:52.380 --> 00:22:58.560
<v Chris Gammell>And in the case of a ventilator, you would definitely, that's, that's priority.

00:22:58.660 --> 00:23:06.000
<v Chris Gammell>Number one, you don't really need to, you know, like tweet the number of, of, uh, breaths

00:23:06.000 --> 00:23:11.620
<v Chris Gammell>the ventilator is provided to the, yeah, you don't, you don't care about any of that kind

00:23:11.620 --> 00:23:12.020
<v Chris Gammell>of stuff.

00:23:12.020 --> 00:23:19.100
<v Chris Gammell>And the other important thing for that high priority critical task is that it's, it can't

00:23:19.100 --> 00:23:22.960
<v Chris Gammell>be waiting on any shared resources from any of the other tasks.

00:23:22.960 --> 00:23:27.340
<v Chris Gammell>So you really want that to be pushing information out.

00:23:27.420 --> 00:23:27.600
<v Chris Gammell>Yeah.

00:23:27.860 --> 00:23:28.140
<v Chris Gammell>Right.

00:23:28.140 --> 00:23:34.480
<v Chris Gammell>So you, you know, you don't want to get into a situation where there's this crazy big block

00:23:34.480 --> 00:23:39.660
<v Chris Gammell>of shared memory and you're waiting on a mutex for something to update.

00:23:39.880 --> 00:23:43.700
<v Chris Gammell>You know, you just want that, you want that critical task to be continuously running.

00:23:44.240 --> 00:23:49.880
<v Chris Gammell>And then when it has information to disperse to the other part of the system, you know,

00:23:49.880 --> 00:23:52.060
<v Chris Gammell>it would do that probably through a queue.

00:23:52.460 --> 00:23:52.860
<v Chris Gammell>Yeah.

00:23:53.000 --> 00:23:54.400
<v Chris Gammell>It'd be a reasonable thing to do.

00:23:54.580 --> 00:23:54.820
<v Brian Amos>Yeah.

00:23:54.820 --> 00:23:59.500
<v Brian Amos>So the other thing that, that kind of, that this, your book opened up for me is like,

00:23:59.520 --> 00:24:02.180
<v Brian Amos>okay, so now you have something that just, it's a task.

00:24:02.180 --> 00:24:03.300
<v Brian Amos>It's just reading a sensor.

00:24:03.300 --> 00:24:09.900
<v Brian Amos>And that just looks, basically, it looks like if you just had a, a single function program

00:24:09.900 --> 00:24:12.860
<v Brian Amos>that was just like spy read, spy read.

00:24:12.960 --> 00:24:14.080
<v Brian Amos>And then it's just a loop basically.

00:24:14.440 --> 00:24:20.920
<v Brian Amos>But instead of like a, and correct me if I'm wrong here, but instead of saying like, wait

00:24:20.920 --> 00:24:26.860
<v Brian Amos>5,000 milliseconds, it says, I'm going to go to sleep for 5,000 milliseconds or whatever

00:24:26.860 --> 00:24:29.120
<v Brian Amos>the, you know, the timing is.

00:24:29.400 --> 00:24:33.680
<v Chris Gammell>You can have super, super fine grain tasks like that.

00:24:33.800 --> 00:24:43.820
<v Chris Gammell>More often they wind up getting segmented more along the lines of like a group of responsibilities,

00:24:43.820 --> 00:24:44.680
<v Chris Gammell>you know?

00:24:45.220 --> 00:24:45.660
<v Brian Amos>Okay.

00:24:45.880 --> 00:24:46.220
<v Chris Gammell>All right.

00:24:46.600 --> 00:24:48.300
<v Chris Gammell>So it would be like sensor package.

00:24:48.300 --> 00:24:54.920
<v Chris Gammell>So it'd be like, yeah, so I would, I mean, and again, this is kind of a, this is getting

00:24:54.920 --> 00:24:56.440
<v Chris Gammell>into design decisions.

00:24:56.440 --> 00:24:56.780
<v Chris Gammell>Right.

00:24:57.280 --> 00:25:07.060
<v Chris Gammell>But typically if I'm, if I'm creating tasks, then they're going to have, it'll be a task.

00:25:07.060 --> 00:25:10.020
<v Chris Gammell>Let's say the, you know, the, the ventilator example, right?

00:25:10.040 --> 00:25:17.220
<v Chris Gammell>It's going to be the, the measurement of your, you know, PSI or whatever it is, is going

00:25:17.220 --> 00:25:17.800
<v Chris Gammell>to be happening.

00:25:18.280 --> 00:25:23.480
<v Chris Gammell>You're going to be taking that measurement in, you're going to be controlling your actuator.

00:25:23.600 --> 00:25:25.200
<v Chris Gammell>All of that is going to be in a single task.

00:25:25.260 --> 00:25:30.300
<v Chris Gammell>You wouldn't necessarily need like two tasks, one for the center, one for the actuator.

00:25:30.300 --> 00:25:30.600
<v Chris Gammell>Right.

00:25:30.700 --> 00:25:39.040
<v Chris Gammell>So, so you're, you're kind of grouping stuff in like tasks and, and, or, you know, like,

00:25:39.120 --> 00:25:39.880
<v Chris Gammell>like functionality.

00:25:40.080 --> 00:25:40.500
<v Chris Gammell>Right.

00:25:40.540 --> 00:25:45.980
<v Chris Gammell>So then you, you push all your IOT stuff and that stack out onto a different lower priority

00:25:45.980 --> 00:25:48.260
<v Chris Gammell>task probably in that example.

00:25:48.260 --> 00:25:53.300
<v Brian Amos>So when, when you make, I mean, you mentioned design decisions, but like when, when do you

00:25:53.300 --> 00:25:54.180
<v Brian Amos>construct that?

00:25:54.260 --> 00:25:59.200
<v Brian Amos>I would imagine that there would be problems if you, like, then you, what if you need to

00:25:59.200 --> 00:26:01.060
<v Brian Amos>go re reconstruct something later?

00:26:01.060 --> 00:26:05.520
<v Brian Amos>Is it tough to, to do that sort of thing and be like, oh, actually no, now we need to have

00:26:05.520 --> 00:26:10.320
<v Brian Amos>the sensor package talk over a cue to the motor instead of having the.

00:26:10.320 --> 00:26:10.800
<v Brian Amos>Oh, it's just like anything else.

00:26:10.800 --> 00:26:13.820
<v Brian Amos>It depends on how much spaghetti you've, you've created first.

00:26:14.040 --> 00:26:14.140
<v Chris Gammell>Right.

00:26:14.820 --> 00:26:16.780
<v Brian Amos>Imagine infinite spaghetti for me.

00:26:17.300 --> 00:26:17.540
<v Chris Gammell>Yeah.

00:26:17.540 --> 00:26:22.320
<v Chris Gammell>So, so really, you know, the, the best thing to do is just to, you, you sketch it out on

00:26:22.320 --> 00:26:29.080
<v Chris Gammell>a napkin and say, Hey, I've, I've got, I have, you know, requirements A, B, and C to take

00:26:29.080 --> 00:26:29.640
<v Chris Gammell>care of.

00:26:30.040 --> 00:26:32.120
<v Chris Gammell>How am I going to accomplish these things?

00:26:32.240 --> 00:26:35.600
<v Chris Gammell>What needs to happen concurrently to the other stuff?

00:26:36.440 --> 00:26:42.440
<v Chris Gammell>Each thing that's going to happen, you know, seemingly in parallel, get its own, would get

00:26:42.440 --> 00:26:43.180
<v Chris Gammell>its own task.

00:26:43.180 --> 00:26:46.920
<v Chris Gammell>If you have some long running stuff, that's low priority that gets its own task.

00:26:46.920 --> 00:26:53.500
<v Chris Gammell>If you have some higher priority things that need to happen with tight time constraints,

00:26:53.500 --> 00:27:00.960
<v Chris Gammell>they either need to go into, you know, ISRs and just deal with them below any of the RTOS

00:27:00.960 --> 00:27:01.340
<v Chris Gammell>stuff.

00:27:01.520 --> 00:27:05.780
<v Chris Gammell>So, you know, in the ISR context, that's going to run no matter what.

00:27:06.200 --> 00:27:06.680
<v Chris Gammell>Right.

00:27:06.680 --> 00:27:13.160
<v Brian Amos>So ISR is interrupt service routine for people that are hardware focused like me.

00:27:13.260 --> 00:27:13.520
<v Brian Amos>Yes.

00:27:14.240 --> 00:27:14.680
<v Chris Gammell>Yep.

00:27:14.780 --> 00:27:15.100
<v Chris Gammell>Yep.

00:27:15.180 --> 00:27:15.320
<v Chris Gammell>Yep.

00:27:15.460 --> 00:27:15.720
<v Chris Gammell>Yeah.

00:27:15.720 --> 00:27:22.800
<v Chris Gammell>So, so all of your interrupts, you're going to configure those so that you're almost always,

00:27:22.800 --> 00:27:30.060
<v Chris Gammell>so that your scheduler interrupt is a lower priority than any of your critical interrupts.

00:27:30.140 --> 00:27:30.340
<v Chris Gammell>Right.

00:27:30.340 --> 00:27:36.720
<v Chris Gammell>So if you have real time sensor data getting streamed back from something, right?

00:27:36.820 --> 00:27:44.420
<v Chris Gammell>So let's say that you're, that pressure sensor on the ventilators is streaming data, then

00:27:44.420 --> 00:27:49.600
<v Chris Gammell>you would make that a higher priority and you would always go out and read that no matter

00:27:49.600 --> 00:27:50.020
<v Chris Gammell>what.

00:27:50.200 --> 00:27:50.420
<v Chris Gammell>Right.

00:27:50.420 --> 00:27:57.100
<v Chris Gammell>And then you can, you can squirrel that data away and then, you know, post a semaphore whenever

00:27:57.100 --> 00:28:00.340
<v Chris Gammell>you have enough of it and it's time to do something with it.

00:28:00.500 --> 00:28:05.140
<v Chris Gammell>And then, you know, at that point, the scheduler takes over and you start having RTOS tasks kind

00:28:05.140 --> 00:28:06.240
<v Chris Gammell>of, you know, spin on.

00:28:06.540 --> 00:28:10.460
<v Brian Amos>I think that was another thing that I didn't quite understand is that you can, so like if

00:28:10.460 --> 00:28:15.040
<v Brian Amos>you're designing a system now, and I had been, you know, kind of in the bare metal working

00:28:15.040 --> 00:28:17.180
<v Brian Amos>with interrupts and getting used to that.

00:28:17.180 --> 00:28:22.580
<v Brian Amos>And then it was like, well, if you're in an RTOS now, you actually don't ever need to

00:28:22.580 --> 00:28:28.160
<v Brian Amos>use an actual hardware interrupt anymore because basically an interrupt is built in.

00:28:28.160 --> 00:28:28.500
<v Brian Amos>You have to be careful there.

00:28:28.740 --> 00:28:31.320
<v Chris Gammell>You have to be very, very careful there.

00:28:31.960 --> 00:28:32.560
<v Chris Gammell>You, I mean, you.

00:28:32.640 --> 00:28:33.020
<v Chris Gammell>Why is that?

00:28:33.260 --> 00:28:35.480
<v Chris Gammell>You can program like that, but.

00:28:35.960 --> 00:28:36.240
<v Brian Amos>Yeah.

00:28:36.600 --> 00:28:40.760
<v Brian Amos>Not as, not as like a wood, but like a, like, cause yeah, I mean, a lot of the sensors I

00:28:40.760 --> 00:28:43.500
<v Brian Amos>use, they, you know, they have a pin that goes high when they're done with it, but they

00:28:43.500 --> 00:28:44.140
<v Brian Amos>never reading ready.

00:28:44.220 --> 00:28:45.920
<v Brian Amos>So I wouldn't want to use that.

00:28:45.920 --> 00:28:52.740
<v Brian Amos>But in the event I didn't have that, I just had like really silly, simple, just analog

00:28:52.740 --> 00:28:53.180
<v Brian Amos>sensors.

00:28:53.180 --> 00:28:57.380
<v Brian Amos>And I, you know, it was just like this interface into an old analog system or something.

00:28:57.560 --> 00:29:01.920
<v Brian Amos>In theory, I don't need to have physical hardware interrupts.

00:29:02.740 --> 00:29:02.840
<v Chris Gammell>Yeah.

00:29:02.920 --> 00:29:07.560
<v Chris Gammell>I mean, you can, if you're, so we have to be a little bit careful here.

00:29:07.560 --> 00:29:07.780
<v Chris Gammell>Right.

00:29:07.840 --> 00:29:11.420
<v Chris Gammell>So depending on how fast.

00:29:11.600 --> 00:29:14.740
<v Brian Amos>Someone, someone in a future design meeting and be like, well, Brian, but on the amp hour,

00:29:14.820 --> 00:29:16.080
<v Brian Amos>you said, you know.

00:29:17.220 --> 00:29:17.540
<v Chris Gammell>So.

00:29:18.140 --> 00:29:20.940
<v Chris Gammell>I mean, you know, how fast are your sensors being read?

00:29:21.700 --> 00:29:22.020
<v Chris Gammell>Right.

00:29:22.180 --> 00:29:22.340
<v Brian Amos>Yeah.

00:29:22.380 --> 00:29:23.500
<v Chris Gammell>I mean, like that's.

00:29:23.560 --> 00:29:25.460
<v Brian Amos>I, I'm not, I'm not, I'm not going to hold you to this here.

00:29:25.460 --> 00:29:29.340
<v Brian Amos>I'm just saying this was, this was my epiphany about it where I, I had kind of always thought

00:29:29.340 --> 00:29:33.980
<v Brian Amos>it was like the two choices were, well, you can have an interrupt driven system where, you

00:29:33.980 --> 00:29:35.040
<v Brian Amos>know, you have these sensors and.

00:29:35.180 --> 00:29:35.540
<v Brian Amos>Oh, I see.

00:29:35.700 --> 00:29:35.980
<v Brian Amos>Yes.

00:29:36.480 --> 00:29:36.600
<v Brian Amos>Yeah.

00:29:36.720 --> 00:29:36.920
<v Brian Amos>Absolutely.

00:29:36.920 --> 00:29:37.040
<v Brian Amos>Exactly.

00:29:37.500 --> 00:29:40.960
<v Brian Amos>Or you're on like just a loop and you're saying, well, I'm going to pull everything.

00:29:41.400 --> 00:29:41.520
<v Brian Amos>Right.

00:29:41.540 --> 00:29:45.980
<v Brian Amos>And this is, this is the epiphany here was like, oh, well, it does bet much better options

00:29:45.980 --> 00:29:47.120
<v Brian Amos>at the middle, which is.

00:29:47.120 --> 00:29:52.940
<v Chris Gammell>But the tricky thing, the one thing to keep in mind is yes, you can write pulling routines

00:29:52.940 --> 00:29:55.700
<v Chris Gammell>inside of a task in an RTOS, right?

00:29:55.740 --> 00:29:58.480
<v Chris Gammell>That's not a, that's perfectly okay to do.

00:29:58.960 --> 00:30:05.960
<v Chris Gammell>But at that point you've, you've still written a pulling routine and your, your CPU still needs

00:30:05.960 --> 00:30:11.160
<v Chris Gammell>to go out and check whatever it's pulling at some interval, right?

00:30:11.160 --> 00:30:16.540
<v Chris Gammell>So you're still using CPU cycles, depending on how fast you want to check that thing.

00:30:18.360 --> 00:30:26.040
<v Chris Gammell>If you can manage to design your hardware in such a way that it goes into an interrupt pin

00:30:26.040 --> 00:30:32.040
<v Chris Gammell>or it starts communicating to a UART and your UART peripheral has, or, you know, USART spy,

00:30:32.140 --> 00:30:33.280
<v Chris Gammell>whatever, whatever it is, right?

00:30:33.280 --> 00:30:36.180
<v Chris Gammell>Some sort of serial peripheral has interrupts.

00:30:36.360 --> 00:30:38.540
<v Chris Gammell>Then those interrupts could be activated.

00:30:39.100 --> 00:30:42.300
<v Chris Gammell>They can bring in a meaningful amount of data from the sensor.

00:30:42.580 --> 00:30:49.400
<v Chris Gammell>And then you can, you know, signal a task to wake up and say, Hey, I've got some useful

00:30:49.400 --> 00:30:53.600
<v Chris Gammell>data rather than that task spending time pulling this thing repeatedly.

00:30:54.060 --> 00:30:54.160
<v Chris Gammell>Yep.

00:30:54.420 --> 00:30:54.560
<v Chris Gammell>Yeah.

00:30:54.560 --> 00:31:00.940
<v Chris Gammell>So you can, you can wind up with more scalable systems that have better response times.

00:31:01.100 --> 00:31:05.400
<v Chris Gammell>If you avoid almost all the pulling possible.

00:31:05.560 --> 00:31:07.040
<v Chris Gammell>Now, of course, with pulling really high.

00:31:07.240 --> 00:31:07.620
<v Chris Gammell>Yeah.

00:31:07.720 --> 00:31:07.940
<v Chris Gammell>Yeah.

00:31:08.020 --> 00:31:08.740
<v Chris Gammell>Pretty much.

00:31:08.800 --> 00:31:08.940
<v Chris Gammell>Right.

00:31:08.940 --> 00:31:13.260
<v Chris Gammell>Like, and that also holds true for, for low power designs too.

00:31:13.260 --> 00:31:18.860
<v Chris Gammell>So, you know, the more things that you can have event driven in a low power design, the better,

00:31:19.080 --> 00:31:24.000
<v Chris Gammell>because the one thing that you kind of get for free, depending on which port of free RTOS

00:31:24.000 --> 00:31:29.400
<v Chris Gammell>you're using, some RTOS is, free RTOS is one of them where they have a tickless mode.

00:31:30.060 --> 00:31:34.160
<v Chris Gammell>And so, you know, like normally in RTOS, it, it has to keep track of time.

00:31:34.160 --> 00:31:34.580
<v Chris Gammell>Right.

00:31:35.140 --> 00:31:38.720
<v Brian Amos>And, you know, just another, another thing that I learned from your book.

00:31:38.760 --> 00:31:38.960
<v Brian Amos>Yes.

00:31:39.640 --> 00:31:39.920
<v Brian Amos>Yeah.

00:31:39.920 --> 00:31:42.840
<v Brian Amos>People are getting a good feeling for just how little I understood about it prior to this.

00:31:43.060 --> 00:31:47.340
<v Chris Gammell>It's, it's a very, you know, time is very important in a real time system as it turns

00:31:47.340 --> 00:31:47.560
<v Chris Gammell>out.

00:31:47.560 --> 00:31:47.960
<v Brian Amos>Yeah.

00:31:47.960 --> 00:31:48.100
<v Brian Amos>Yeah.

00:31:48.100 --> 00:31:48.260
<v Brian Amos>Yeah.

00:31:48.580 --> 00:31:48.940
<v Chris Gammell>Yeah.

00:31:49.020 --> 00:31:56.280
<v Chris Gammell>So, so if you have a, a fully event driven system and it needs to be low power and you need

00:31:56.280 --> 00:32:01.160
<v Chris Gammell>reasonable, you know, like, let's say you want like millisecond time resolution for whatever

00:32:01.160 --> 00:32:01.740
<v Chris Gammell>reason, right?

00:32:02.300 --> 00:32:07.700
<v Chris Gammell>You really don't want your processor waking up from an interrupt every millisecond.

00:32:07.840 --> 00:32:10.320
<v Chris Gammell>That would be, you know, that's the battery killer.

00:32:10.600 --> 00:32:10.900
<v Chris Gammell>Yeah.

00:32:11.020 --> 00:32:11.880
<v Chris Gammell>That'd be terrible.

00:32:12.900 --> 00:32:15.360
<v Chris Gammell>So they have modes.

00:32:15.540 --> 00:32:20.880
<v Chris Gammell>If you, again, try and avoid the pulling route as much as possible, create everything to be

00:32:20.880 --> 00:32:21.400
<v Chris Gammell>event driven.

00:32:21.720 --> 00:32:26.680
<v Chris Gammell>And you can go into a tickless mode where if you have something to do, let's say once a

00:32:26.680 --> 00:32:31.760
<v Chris Gammell>week, you know, and you're using hardware that has the capability with a real time clock

00:32:31.760 --> 00:32:37.920
<v Chris Gammell>with an alarm, you can set everything up so that the whole chip gets powered down, except

00:32:37.920 --> 00:32:38.800
<v Chris Gammell>for that RTC.

00:32:39.340 --> 00:32:43.260
<v Chris Gammell>It wakes up in a week and then it's time to do whatever you need to do.

00:32:43.480 --> 00:32:45.320
<v Chris Gammell>Then it goes right back to sleep again.

00:32:45.660 --> 00:32:51.280
<v Chris Gammell>And, you know, there's no CPU intervention necessary, you know, between that time, obviously,

00:32:51.520 --> 00:32:54.700
<v Chris Gammell>you know, at that point you start talking about clock drift and that kind of stuff.

00:32:54.700 --> 00:33:01.860
<v Chris Gammell>But, you know, that's where crystals versus RC oscillators start to become kind of important

00:33:01.860 --> 00:33:03.380
<v Chris Gammell>for your RTC stuff.

00:33:03.660 --> 00:33:08.760
<v Brian Amos>But yeah, I'm just surprised that I didn't get into this sooner, I guess.

00:33:08.880 --> 00:33:10.520
<v Brian Amos>I mean, like I should say get into this.

00:33:10.600 --> 00:33:11.700
<v Brian Amos>I mean, read about it sooner.

00:33:11.880 --> 00:33:12.320
<v Brian Amos>I don't know.

00:33:12.480 --> 00:33:13.840
<v Brian Amos>How did you learn all this stuff?

00:33:14.520 --> 00:33:17.020
<v Brian Amos>I mean, where did this all come from?

00:33:17.980 --> 00:33:19.380
<v Chris Gammell>I don't, I don't, I remember.

00:33:19.380 --> 00:33:21.880
<v Chris Gammell>I'm not sure how I, okay.

00:33:22.020 --> 00:33:30.480
<v Chris Gammell>So the first time, my first exposure to, it was, it was actually like an anti-RTOS.

00:33:30.760 --> 00:33:38.340
<v Chris Gammell>So I was working, I was working for a company and we were developing a vibration monitoring

00:33:38.340 --> 00:33:40.780
<v Chris Gammell>sensor that was living on a mesh network.

00:33:40.780 --> 00:33:47.560
<v Chris Gammell>And so it was like, you know, a mesh network, mesh wireless network, right?

00:33:47.900 --> 00:33:52.000
<v Chris Gammell>And this thing was supposed to wake up every once in a while and capture a waveform and

00:33:52.000 --> 00:33:53.680
<v Chris Gammell>then send it back to wherever.

00:33:53.680 --> 00:34:00.260
<v Chris Gammell>And some, you know, some senior engineer had decided that, oh, there's this thing called

00:34:00.260 --> 00:34:03.760
<v Chris Gammell>a Telos module made by a company.

00:34:03.860 --> 00:34:11.840
<v Chris Gammell>This is back in, oh geez, probably like 2007, 2008 or so.

00:34:12.500 --> 00:34:14.880
<v Chris Gammell>And there's this Telos module.

00:34:15.120 --> 00:34:21.380
<v Chris Gammell>It was developed using this operating system called TinyOS using a language called Nessi.

00:34:21.380 --> 00:34:25.220
<v Chris Gammell>And so, you know, a whole bunch of really obscure stuff.

00:34:25.420 --> 00:34:26.300
<v Brian Amos>This is sounding good.

00:34:26.380 --> 00:34:27.000
<v Brian Amos>Yeah, yeah, yeah.

00:34:27.680 --> 00:34:31.860
<v Chris Gammell>So anyway, that was my, that was like, well, what, what the heck is this?

00:34:31.920 --> 00:34:33.760
<v Chris Gammell>Oh, it's this little operating system.

00:34:33.760 --> 00:34:36.500
<v Chris Gammell>It's like an, an anti-real-time operating system.

00:34:36.620 --> 00:34:37.700
<v Brian Amos>It's like, what the hell does that mean?

00:34:38.660 --> 00:34:41.400
<v Chris Gammell>Well, it basically tries not to do anything.

00:34:41.680 --> 00:34:42.000
<v Brian Amos>Bullet time.

00:34:42.160 --> 00:34:42.880
<v Brian Amos>It's bullet time.

00:34:44.240 --> 00:34:49.800
<v Chris Gammell>It's like, it, it tries to push off as much as it can to do later so that it doesn't need

00:34:49.800 --> 00:34:52.180
<v Chris Gammell>to wake up because that costs, that costs power.

00:34:52.440 --> 00:34:53.260
<v Chris Gammell>We don't want to do that.

00:34:53.560 --> 00:34:55.420
<v Brian Amos>It's like a, it's like a sleepy time, sleepy time.

00:34:55.800 --> 00:34:57.060
<v Chris Gammell>That's exactly what it was.

00:34:57.060 --> 00:34:59.940
<v Chris Gammell>So, so they would batch up these processes.

00:34:59.940 --> 00:35:03.600
<v Chris Gammell>So you had all this, all the, the interrupt level stuff, right?

00:35:03.600 --> 00:35:06.000
<v Chris Gammell>And then you would just effectively like post it to a queue.

00:35:06.000 --> 00:35:13.020
<v Chris Gammell>And then at a certain schedule and the schedule could be like at one Hertz or, you know, once

00:35:13.020 --> 00:35:17.900
<v Chris Gammell>every five seconds or whatever, the, the processor would wake up and it would chug

00:35:17.900 --> 00:35:24.480
<v Chris Gammell>through all the stuff that it had to do and, you know, whatever, whatever those kinds of

00:35:24.480 --> 00:35:29.220
<v Chris Gammell>tasks needed to be, needed to have their stuff done.

00:35:29.300 --> 00:35:32.260
<v Chris Gammell>And she was like, okay, here, I'm, I'm good.

00:35:32.460 --> 00:35:35.280
<v Chris Gammell>I have taken care of all of my duties.

00:35:35.280 --> 00:35:40.420
<v Chris Gammell>I'm going back to sleep for another five seconds or whatever that, whatever that was.

00:35:40.520 --> 00:35:42.500
<v Chris Gammell>But that was my first exposure to it.

00:35:42.540 --> 00:35:44.900
<v Chris Gammell>So I was like, okay, there is such a thing as.

00:35:44.900 --> 00:35:49.760
<v Chris Gammell>You know, like an operating system and this is all, this is on MSP four thirties.

00:35:50.180 --> 00:35:52.640
<v Brian Amos>Oh, so already pretty, pretty low power to start with.

00:35:52.640 --> 00:35:52.880
<v Brian Amos>Yeah.

00:35:52.880 --> 00:35:54.080
<v Chris Gammell>So there are low power to start with.

00:35:54.160 --> 00:35:59.800
<v Chris Gammell>And these are like little 16, 16 bit microcontrollers that had, I don't know.

00:35:59.840 --> 00:36:04.160
<v Chris Gammell>I want to say that the, the code size of that thing was like 14 kilobytes.

00:36:04.160 --> 00:36:12.920
<v Chris Gammell>So it was like, okay, this doesn't need to be super, you know, have super high end microcontrollers

00:36:12.920 --> 00:36:13.840
<v Chris Gammell>or any of that kind of stuff.

00:36:13.980 --> 00:36:19.700
<v Chris Gammell>But yeah, so that was my first exposure to an operating system running on a microcontroller.

00:36:19.940 --> 00:36:24.420
<v Chris Gammell>And then later, you know, we, we found out, I think it was like the other big one around

00:36:24.420 --> 00:36:24.740
<v Chris Gammell>then.

00:36:24.940 --> 00:36:28.220
<v Chris Gammell>I want to say Contiki, but I'm not real sure.

00:36:28.420 --> 00:36:30.160
<v Chris Gammell>I don't think that lasted very long.

00:36:30.160 --> 00:36:35.040
<v Chris Gammell>And TinyOS kind of went by the wayside because they figured out that Ness C wasn't a great,

00:36:35.260 --> 00:36:38.640
<v Chris Gammell>they were writing the operating system in, and all the modules.

00:36:39.780 --> 00:36:43.800
<v Chris Gammell>Ness C was like a really cool combination of structural VHDL and C.

00:36:44.880 --> 00:36:47.740
<v Chris Gammell>So it was very, very modular.

00:36:48.220 --> 00:36:55.780
<v Chris Gammell>And I wound up, they kind of infected me with, with their design methodology because they would

00:36:55.780 --> 00:36:58.940
<v Chris Gammell>have these hardware presentation layers at the very, very bottom.

00:36:59.120 --> 00:37:06.340
<v Chris Gammell>And the job of an HPL was to expose like all the registers of a, of a given chip, right?

00:37:06.400 --> 00:37:08.960
<v Chris Gammell>So you had access to absolutely everything that thing did.

00:37:09.120 --> 00:37:12.780
<v Chris Gammell>And then above that, you have, you know, like this hardware abstraction layer.

00:37:12.780 --> 00:37:19.100
<v Chris Gammell>And the goal of the hardware abstraction layer was that you provide, let's say you have,

00:37:19.200 --> 00:37:21.940
<v Chris Gammell>you know, like an ADC or something like that.

00:37:22.200 --> 00:37:27.560
<v Chris Gammell>Your hardware abstraction layer just provides like a single function, maybe, or like read

00:37:27.560 --> 00:37:28.400
<v Chris Gammell>ADC and get back.

00:37:28.400 --> 00:37:29.140
<v Chris Gammell>It's like ADC read.

00:37:29.400 --> 00:37:29.480
<v Chris Gammell>Yeah.

00:37:29.820 --> 00:37:30.440
<v Chris Gammell>And that's it.

00:37:30.600 --> 00:37:30.720
<v Chris Gammell>Yeah.

00:37:30.920 --> 00:37:37.020
<v Chris Gammell>But the cool part about that design methodology in combination with this really cool structural

00:37:37.020 --> 00:37:43.580
<v Chris Gammell>VHDL kind of like routing stuff that they had was that it, your, your code was immediately

00:37:43.580 --> 00:37:47.840
<v Chris Gammell>portable and it didn't, it didn't matter what processor it was running on.

00:37:47.900 --> 00:37:53.300
<v Chris Gammell>It didn't matter, you know, the underlying IC that you're using, as long as you had written

00:37:53.300 --> 00:37:58.700
<v Chris Gammell>all that stuff and the top level code existed and it was there and, you know, you guarantee

00:37:58.700 --> 00:37:59.620
<v Chris Gammell>that it was going to work.

00:38:00.020 --> 00:38:03.620
<v Brian Amos>So when you pour it to a new chip, you just have to rewrite the VHDL ish piece.

00:38:03.620 --> 00:38:04.060
<v Brian Amos>Yeah.

00:38:04.180 --> 00:38:09.180
<v Chris Gammell>So like if you have the same chip in two different boards and let's say you move some GPIO lines

00:38:09.180 --> 00:38:13.540
<v Chris Gammell>around or something like that, then in that case you would like rewrite your, your, your

00:38:13.540 --> 00:38:16.660
<v Chris Gammell>routes and all that kind of stuff with a VHDL ish thing.

00:38:16.820 --> 00:38:23.860
<v Chris Gammell>And then if you moved processors, then you would need to, you know, like rewrite the routines

00:38:23.860 --> 00:38:29.040
<v Chris Gammell>that access GPIO registers and the stuff that accessed your peripherals, right?

00:38:29.060 --> 00:38:31.820
<v Chris Gammell>Like timer peripherals, serial peripherals, that kind of stuff.

00:38:31.820 --> 00:38:41.740
<v Chris Gammell>But yeah, so, and I, I've fully adopted that approach and it, you know, it's served me quite

00:38:41.740 --> 00:38:43.160
<v Chris Gammell>well over the years.

00:38:43.160 --> 00:38:43.660
<v Chris Gammell>Yeah.

00:38:43.880 --> 00:38:44.100
<v Chris Gammell>Yeah.

00:38:44.180 --> 00:38:44.320
<v Chris Gammell>Yeah.

00:38:44.320 --> 00:38:49.780
<v Chris Gammell>To the point where you can, you know, using that level of abstraction, you can very easily

00:38:49.780 --> 00:38:56.640
<v Chris Gammell>write drivers for an IC and have them map across, you know, chips, boards, architectures

00:38:56.640 --> 00:38:57.580
<v Chris Gammell>doesn't, doesn't matter.

00:38:57.780 --> 00:39:04.180
<v Chris Gammell>So it, it pays dividends in the long run to, to architect things properly with a decent abstraction.

00:39:04.980 --> 00:39:05.020
<v Brian Amos>Yeah.

00:39:05.060 --> 00:39:07.860
<v Brian Amos>And like for testing then too, I'm sure that makes it easier for that as well.

00:39:08.020 --> 00:39:08.220
<v Chris Gammell>Yeah.

00:39:08.220 --> 00:39:09.380
<v Chris Gammell>Well, that, that's the funny part.

00:39:09.380 --> 00:39:15.160
<v Chris Gammell>So I didn't, I found out about, you know, things like test driven development and all

00:39:15.160 --> 00:39:16.840
<v Chris Gammell>that much later.

00:39:17.560 --> 00:39:24.220
<v Chris Gammell>And, you know, like I, I remember reading James Grenning's book, TDD with embedded C, or I

00:39:24.220 --> 00:39:27.700
<v Chris Gammell>forget the title of it exactly, but test driven development with embedded C.

00:39:27.700 --> 00:39:36.480
<v Chris Gammell>I think I was like, man, all of my code is like super easy to test because it uses these

00:39:36.480 --> 00:39:37.640
<v Chris Gammell>well-defined interfaces.

00:39:37.840 --> 00:39:38.440
<v Chris Gammell>What do you know?

00:39:38.880 --> 00:39:39.000
<v Brian Amos>Yeah.

00:39:39.260 --> 00:39:39.460
<v Brian Amos>Yeah.

00:39:39.700 --> 00:39:39.920
<v Brian Amos>Yeah.

00:39:40.340 --> 00:39:40.780
<v Brian Amos>Right.

00:39:40.840 --> 00:39:44.800
<v Brian Amos>Versus like, I'm sure the code that I write, which is like, it's all in one file.

00:39:45.480 --> 00:39:45.960
<v Brian Amos>Yeah.

00:39:46.020 --> 00:39:47.000
<v Chris Gammell>All in one file.

00:39:47.440 --> 00:39:48.360
<v Chris Gammell>That's bad.

00:39:48.600 --> 00:39:48.920
<v Chris Gammell>That's bad.

00:39:49.080 --> 00:39:52.080
<v Chris Gammell>Exclusively uses registers directly with, you know.

00:39:52.260 --> 00:39:52.480
<v Chris Gammell>Yep.

00:39:52.560 --> 00:39:52.760
<v Chris Gammell>Yep.

00:39:52.760 --> 00:39:52.940
<v Chris Gammell>Yep.

00:39:53.180 --> 00:39:53.400
<v Chris Gammell>Yeah.

00:39:53.400 --> 00:39:58.020
<v Chris Gammell>Got to do the bitwise math to get access to anything.

00:39:59.000 --> 00:39:59.480
<v Chris Gammell>Yeah.

00:39:59.580 --> 00:40:01.660
<v Chris Gammell>So, so, you know, multiple files is good.

00:40:02.300 --> 00:40:02.460
<v Chris Gammell>Yep.

00:40:02.460 --> 00:40:05.720
<v Chris Gammell>Giving names to the bit, to the bits is also good.

00:40:05.920 --> 00:40:12.520
<v Chris Gammell>You know, long strings, like, especially now with 32 bit processors, you know, long strings

00:40:12.520 --> 00:40:17.420
<v Chris Gammell>of, uh, of binary is not, not favored.

00:40:17.580 --> 00:40:17.700
<v Chris Gammell>Yeah.

00:40:17.700 --> 00:40:17.780
<v Chris Gammell>Yeah.

00:40:19.200 --> 00:40:24.640
<v Brian Amos>So at some point, I'm sure you've had the thought I should just write my own real-time

00:40:24.640 --> 00:40:25.400
<v Brian Amos>operating system.

00:40:25.720 --> 00:40:25.860
<v Brian Amos>Never.

00:40:25.860 --> 00:40:27.000
<v Brian Amos>Because it feels like that's.

00:40:27.100 --> 00:40:27.300
<v Brian Amos>Nope.

00:40:27.480 --> 00:40:27.780
<v Brian Amos>Really?

00:40:28.000 --> 00:40:28.160
<v Brian Amos>Nope.

00:40:28.160 --> 00:40:28.300
<v Brian Amos>Okay.

00:40:28.600 --> 00:40:32.600
<v Brian Amos>It's, it feels like the other reading that I've done around this was from Jack Gansel.

00:40:32.600 --> 00:40:39.080
<v Brian Amos>And it's like, it was like, uh, yeah, the, the primary, the number one RTOS out there

00:40:39.080 --> 00:40:40.240
<v Brian Amos>is, uh, custom.

00:40:40.240 --> 00:40:40.640
<v Brian Amos>Yeah.

00:40:41.840 --> 00:40:48.660
<v Chris Gammell>And, you know, like at some point, if a program becomes sufficiently complicated, you're, you're

00:40:48.660 --> 00:40:50.080
<v Chris Gammell>kind of forced into it, right?

00:40:51.040 --> 00:40:58.060
<v Chris Gammell>Because, you know, you have some routine that's chugging through a complex math calculation or

00:40:58.060 --> 00:40:58.420
<v Chris Gammell>whatever.

00:40:58.560 --> 00:40:59.000
<v Chris Gammell>Right.

00:40:59.060 --> 00:41:04.940
<v Chris Gammell>And in the middle of that, you need to check to see if your, your buffer is overflowing

00:41:04.940 --> 00:41:05.480
<v Chris Gammell>or whatever.

00:41:05.480 --> 00:41:10.080
<v Chris Gammell>So you wind up with all these reads, these unrelated things sprinkled throughout.

00:41:10.240 --> 00:41:12.440
<v Chris Gammell>Uh, this long running process.

00:41:13.540 --> 00:41:18.580
<v Chris Gammell>And yeah, no, I, I have no desire to, to write my own, to roll my own RTOS.

00:41:18.960 --> 00:41:23.560
<v Chris Gammell>I'm very happy and grateful that other people are, are capable of.

00:41:23.660 --> 00:41:24.020
<v Chris Gammell>That's great.

00:41:24.260 --> 00:41:24.460
<v Chris Gammell>Yeah.

00:41:24.460 --> 00:41:24.660
<v Chris Gammell>Okay.

00:41:24.840 --> 00:41:25.120
<v Brian Amos>Yeah.

00:41:25.120 --> 00:41:26.980
<v Brian Amos>I thought I was going to, I thought I was going to trap you on that one, Brian.

00:41:27.060 --> 00:41:27.860
<v Brian Amos>You, you passed the test.

00:41:29.440 --> 00:41:30.160
<v Brian Amos>No, no, no.

00:41:30.960 --> 00:41:31.980
<v Brian Amos>People watch bugger than me.

00:41:31.980 --> 00:41:34.820
<v Brian Amos>Actually, I would like to announce my new Brian RTOS.

00:41:35.020 --> 00:41:35.940
<v Brian Amos>No, no.

00:41:36.100 --> 00:41:37.080
<v Brian Amos>I've announced you're in the Empire.

00:41:37.080 --> 00:41:37.560
<v Brian Amos>Yeah.

00:41:37.560 --> 00:41:44.900
<v Chris Gammell>I, I, I almost accidentally recreated portions of GRPC and for a project and I, I kicked my

00:41:44.900 --> 00:41:45.040
<v Chris Gammell>saw.

00:41:45.100 --> 00:41:46.100
<v Chris Gammell>I just didn't know about it.

00:41:48.800 --> 00:41:49.160
<v Brian Amos>Yeah.

00:41:49.320 --> 00:41:52.820
<v Brian Amos>That's good to, I mean, and that's what it kind of comes down to for a lot of this stuff

00:41:52.820 --> 00:41:54.960
<v Brian Amos>is like, I don't know.

00:41:54.960 --> 00:41:59.280
<v Brian Amos>So, I don't know when I, okay, I, I was in the hardware side for a long time and I'm

00:41:59.280 --> 00:42:03.180
<v Brian Amos>trying to learn more of this stuff, but I just don't know when I would have learned this.

00:42:03.240 --> 00:42:06.160
<v Brian Amos>I'm sure some people learn this in school, I guess.

00:42:06.300 --> 00:42:06.780
<v Brian Amos>I don't know.

00:42:06.780 --> 00:42:10.740
<v Chris Gammell>I mean, I, I had a, so I, I have a computer engineering degree, right?

00:42:10.740 --> 00:42:14.480
<v Chris Gammell>So it's, it's like a combination of hardware and software.

00:42:14.480 --> 00:42:19.580
<v Chris Gammell>So I, I focused on embedded systems in college and I, there was an operating systems course

00:42:19.580 --> 00:42:20.800
<v Chris Gammell>and I, you know, I took it.

00:42:20.800 --> 00:42:23.400
<v Brian Amos>Was it, was it meant for embedded operating systems?

00:42:23.660 --> 00:42:24.620
<v Brian Amos>No, no, it wasn't.

00:42:24.700 --> 00:42:25.820
<v Brian Amos>Everything was, you know, it was all Linux.

00:42:25.840 --> 00:42:25.980
<v Brian Amos>Yeah.

00:42:25.980 --> 00:42:28.980
<v Brian Amos>It's like for writing Linux or Windows, right?

00:42:29.400 --> 00:42:29.640
<v Brian Amos>Yeah.

00:42:29.720 --> 00:42:29.900
<v Brian Amos>Yeah.

00:42:29.900 --> 00:42:33.020
<v Chris Gammell>It was like, you know, it was basically a systems programming course more or less.

00:42:33.200 --> 00:42:37.620
<v Chris Gammell>And, you know, it was just, they taught you the basics of things and that was that.

00:42:38.840 --> 00:42:44.640
<v Chris Gammell>But yeah, I didn't really see a whole lot of utility for it until, you know, until you

00:42:44.640 --> 00:42:50.180
<v Chris Gammell>have that first project where it's like, man, this is a little bit more complicated to do.

00:42:50.800 --> 00:42:51.080
<v Chris Gammell>Yeah.

00:42:51.520 --> 00:42:52.740
<v Chris Gammell>And just a super loop.

00:42:53.700 --> 00:42:53.760
<v Chris Gammell>So.

00:42:54.380 --> 00:42:54.700
<v Brian Amos>Yes.

00:42:54.880 --> 00:42:55.400
<v Brian Amos>Right, right, right.

00:42:56.040 --> 00:42:56.400
<v Brian Amos>Yeah.

00:42:56.520 --> 00:42:59.940
<v Brian Amos>And, and again, you would, you would cross that threshold.

00:43:00.100 --> 00:43:05.080
<v Brian Amos>You would, you would, so say you had a super loop project and then you were like, oh, this

00:43:05.080 --> 00:43:05.900
<v Brian Amos>is not going to be good.

00:43:06.560 --> 00:43:08.500
<v Brian Amos>When do you, when do you pull the trigger?

00:43:08.580 --> 00:43:11.640
<v Brian Amos>When should people listening, I suppose it's the real thing, you know, and I guess including

00:43:11.640 --> 00:43:18.640
<v Brian Amos>me, when should people make that, like just bear down and make the switch?

00:43:18.640 --> 00:43:26.240
<v Chris Gammell>Well, you know, the first time you converting stuff is, can be surprisingly difficult, especially

00:43:26.240 --> 00:43:33.200
<v Chris Gammell>when you're new, you know, converting like a super loop program into, if you're the original

00:43:33.200 --> 00:43:38.040
<v Chris Gammell>author of it, then, you know, you at least know about most of the stuff that you haven't,

00:43:38.140 --> 00:43:44.360
<v Chris Gammell>you know, like, okay, I know that this system requirement runs and it's like, I've got requirements

00:43:44.360 --> 00:43:47.740
<v Chris Gammell>ABC and I know that all of those things exist.

00:43:48.060 --> 00:43:52.840
<v Chris Gammell>So then you say, okay, well, can I make requirement A into a task requirement B into a task requirement

00:43:52.840 --> 00:43:53.060
<v Chris Gammell>C?

00:43:53.060 --> 00:44:03.200
<v Chris Gammell>So the, it's really, if you find yourself sprinkling in calls that check on unrelated processes

00:44:03.200 --> 00:44:06.100
<v Chris Gammell>in the middle of a long running process, right?

00:44:06.200 --> 00:44:10.980
<v Chris Gammell>Like let's say, oh geez, let's say you have a block of data that you need to do some math

00:44:10.980 --> 00:44:11.240
<v Chris Gammell>on.

00:44:12.380 --> 00:44:19.900
<v Chris Gammell>And, you know, so there's a loop and you find yourself adding like, oh, every hundred iterations

00:44:19.900 --> 00:44:26.840
<v Chris Gammell>of this loop, I should, I need to go check on the UART to make sure that I don't get, you

00:44:26.840 --> 00:44:30.140
<v Chris Gammell>know, a buffer overflow and I don't drop characters.

00:44:30.520 --> 00:44:36.640
<v Chris Gammell>Like at that point, you know, that long running, that long running algorithm should probably be

00:44:36.640 --> 00:44:37.520
<v Chris Gammell>in its own task.

00:44:37.700 --> 00:44:42.500
<v Chris Gammell>And, you know, there should be a different way of accessing the data and making sure that

00:44:42.500 --> 00:44:48.760
<v Chris Gammell>the UART, because the UART ISR isn't really, you know, it's not really like a big deal necessarily,

00:44:48.760 --> 00:44:53.340
<v Chris Gammell>or maybe it is, and you actually need to break out of that long running task and, you know,

00:44:53.860 --> 00:44:59.760
<v Chris Gammell>go service that, that thing, that frame that just came across your, your serial line or whatever,

00:44:59.900 --> 00:45:00.120
<v Chris Gammell>right?

00:45:00.900 --> 00:45:03.500
<v Chris Gammell>It could be an abort, right?

00:45:04.040 --> 00:45:07.960
<v Chris Gammell>I've got this, I've got this calculation that takes 30 seconds to do.

00:45:08.140 --> 00:45:12.740
<v Chris Gammell>And, you know, you could just imagine someone like, you know, hitting a push button, like,

00:45:12.740 --> 00:45:14.140
<v Chris Gammell>you know, stop it, stop, stop.

00:45:15.240 --> 00:45:21.060
<v Chris Gammell>So, you know, attach, attach the interrupt of the push button to a, to a semaphore and,

00:45:21.060 --> 00:45:22.200
<v Chris Gammell>you know, yank.

00:45:23.260 --> 00:45:23.740
<v Chris Gammell>Yep.

00:45:25.100 --> 00:45:25.820
<v Brian Amos>But, okay.

00:45:25.820 --> 00:45:29.540
<v Brian Amos>So let's go back to the, so the, uh, the ventilator example.

00:45:29.540 --> 00:45:35.220
<v Brian Amos>The one thing I wanted to ask you about that is, so you have this super high priority task,

00:45:35.360 --> 00:45:36.960
<v Brian Amos>like keeping someone alive.

00:45:38.560 --> 00:45:39.800
<v Brian Amos>Why isn't that always just running?

00:45:39.800 --> 00:45:41.740
<v Chris Gammell>I mean, what's it doing, right?

00:45:42.240 --> 00:45:44.280
<v Chris Gammell>So does it ever have any.

00:45:44.280 --> 00:45:47.560
<v Brian Amos>I guess when I hear something like high priority, I just think like, well, that's always going

00:45:47.560 --> 00:45:48.600
<v Brian Amos>to be, you know, that's the highest priority.

00:45:48.720 --> 00:45:49.260
<v Brian Amos>It's always running.

00:45:49.460 --> 00:45:50.860
<v Brian Amos>So is that not the case?

00:45:51.420 --> 00:45:52.080
<v Brian Amos>Well, if.

00:45:52.380 --> 00:45:53.480
<v Brian Amos>I'm setting you up for a dunk here.

00:45:53.520 --> 00:45:56.600
<v Brian Amos>If you couldn't, if you couldn't tell, this is a very obviously not the case.

00:45:56.980 --> 00:45:57.340
<v Brian Amos>Yeah.

00:45:57.380 --> 00:46:01.200
<v Chris Gammell>So it is, if you're, it's always running, if it has something to do.

00:46:02.240 --> 00:46:02.720
<v Chris Gammell>Got it.

00:46:02.720 --> 00:46:10.140
<v Chris Gammell>But the minute that your high priority task needs to wait on something, like let's say

00:46:10.140 --> 00:46:15.660
<v Chris Gammell>it's, it's set up to, I mean, I don't, sorry, I don't know anything about ventilators, but

00:46:15.660 --> 00:46:16.600
<v Chris Gammell>let's say it's set up.

00:46:16.960 --> 00:46:17.360
<v Chris Gammell>Yeah.

00:46:17.360 --> 00:46:18.220
<v Chris Gammell>I don't need to operate.

00:46:20.320 --> 00:46:25.780
<v Chris Gammell>Say it's set up to operate at like, I don't know, 20 Hertz, a hundred Hertz, whatever it

00:46:25.780 --> 00:46:26.040
<v Chris Gammell>is.

00:46:26.040 --> 00:46:28.880
<v Chris Gammell>And it's going to evaluate human scale stuff.

00:46:29.100 --> 00:46:29.200
<v Chris Gammell>Right.

00:46:29.300 --> 00:46:29.440
<v Chris Gammell>Right.

00:46:29.480 --> 00:46:36.360
<v Chris Gammell>You know, it's not super fast and you, you want to run this control algorithm for the

00:46:36.360 --> 00:46:37.800
<v Chris Gammell>ventilator at a rate of a hundred Hertz.

00:46:37.920 --> 00:46:43.420
<v Chris Gammell>Well, you're either, you know, you're probably going to set it up so that you have like streaming

00:46:43.420 --> 00:46:44.840
<v Chris Gammell>data coming back from your sensor.

00:46:45.060 --> 00:46:45.360
<v Chris Gammell>Right.

00:46:45.900 --> 00:46:48.540
<v Chris Gammell>So you already have data available.

00:46:48.680 --> 00:46:50.020
<v Chris Gammell>You don't need to wait on anything.

00:46:50.020 --> 00:46:58.120
<v Chris Gammell>And then you take the necessary steps for actuating, you know, the thing that you're the pump or

00:46:58.120 --> 00:46:58.380
<v Chris Gammell>whatever.

00:47:00.200 --> 00:47:07.320
<v Chris Gammell>Well, your processor is running probably at least several, if not tens or hundreds of megahertz,

00:47:07.460 --> 00:47:11.400
<v Chris Gammell>which is a lot faster than a hundred Hertz.

00:47:11.720 --> 00:47:11.820
<v Chris Gammell>Right.

00:47:12.440 --> 00:47:12.760
<v Brian Amos>Right.

00:47:12.960 --> 00:47:13.180
<v Brian Amos>Right.

00:47:13.440 --> 00:47:13.600
<v Brian Amos>Yeah.

00:47:13.600 --> 00:47:14.200
<v Brian Amos>So you have what?

00:47:14.260 --> 00:47:15.280
<v Brian Amos>10, 10 milliseconds.

00:47:15.520 --> 00:47:19.600
<v Brian Amos>When, if, if you split it all into a hundred, second into a hundred, right, you'd have 10 total

00:47:19.600 --> 00:47:21.240
<v Brian Amos>milliseconds for each window.

00:47:21.680 --> 00:47:24.080
<v Brian Amos>So it probably doesn't take 10 milliseconds to read a sensor.

00:47:24.560 --> 00:47:25.220
<v Chris Gammell>Probably not.

00:47:25.280 --> 00:47:25.500
<v Chris Gammell>Right.

00:47:25.560 --> 00:47:29.640
<v Chris Gammell>And, you know, especially if you've, if you've taken care of all of that in, inside of an

00:47:29.640 --> 00:47:30.000
<v Chris Gammell>ISR.

00:47:30.100 --> 00:47:34.400
<v Chris Gammell>So, you know, let's say it takes, it takes a millisecond for this thing to run.

00:47:34.460 --> 00:47:38.660
<v Chris Gammell>What are you, what's that task doing for the other nine milliseconds?

00:47:39.280 --> 00:47:39.640
<v Chris Gammell>Right.

00:47:39.640 --> 00:47:41.760
<v Chris Gammell>Well, that's, it's not running.

00:47:42.360 --> 00:47:42.800
<v Chris Gammell>Right.

00:47:42.800 --> 00:47:49.600
<v Chris Gammell>Because it's either calling a sleep function or it's waiting on some sort of a, you know,

00:47:49.600 --> 00:47:52.460
<v Chris Gammell>like a semaphore that's being generated by a hardware timer.

00:47:52.640 --> 00:47:57.620
<v Chris Gammell>If you want some nice, accurate, you know, every 10 milliseconds on, on the dot.

00:47:58.280 --> 00:47:58.760
<v Chris Gammell>Yep.

00:47:59.240 --> 00:48:00.860
<v Chris Gammell>It's, it's just, it's not doing anything.

00:48:00.860 --> 00:48:05.060
<v Chris Gammell>So then your other tasks are going to run.

00:48:05.320 --> 00:48:12.960
<v Chris Gammell>And if you don't have other tasks that run, then in the case of a non tickless mode, your

00:48:12.960 --> 00:48:18.360
<v Chris Gammell>idle task is going to just sit there and check to see if it's time to bring in another task

00:48:18.360 --> 00:48:19.480
<v Chris Gammell>or run the scheduler.

00:48:19.580 --> 00:48:19.680
<v Brian Amos>Yeah.

00:48:20.020 --> 00:48:23.700
<v Chris Gammell>And if you're in, you know, if you're fortunate enough to be running a, well, not fortunate

00:48:23.700 --> 00:48:28.440
<v Chris Gammell>enough to be, if you're running a tickless version of an OS, the whole chip just goes to

00:48:28.440 --> 00:48:28.640
<v Chris Gammell>sleep.

00:48:28.640 --> 00:48:30.620
<v Chris Gammell>Well, not the whole chip, but the CPU, right.

00:48:30.640 --> 00:48:33.120
<v Chris Gammell>And you can go into the power, whatever parts, right.

00:48:33.440 --> 00:48:37.360
<v Chris Gammell>Whatever, you know, power down, whatever you need to and go to sleep for a little while.

00:48:37.960 --> 00:48:41.340
<v Chris Gammell>So, so yeah, it's, it's not running because it doesn't have anything to do.

00:48:42.140 --> 00:48:45.120
<v Chris Gammell>It's, it's got nothing, it's got nothing to do, but wait.

00:48:45.300 --> 00:48:47.080
<v Chris Gammell>So that's, that's the reason it doesn't run.

00:48:47.160 --> 00:48:53.620
<v Chris Gammell>But the second that it does, it will be running as long as you haven't kind of, you know, screwed

00:48:53.620 --> 00:48:54.140
<v Chris Gammell>things up.

00:48:54.140 --> 00:48:59.060
<v Chris Gammell>And now all of a sudden it's got to wait for a different lower priority task.

00:48:59.520 --> 00:48:59.840
<v Chris Gammell>Right.

00:49:00.160 --> 00:49:01.540
<v Chris Gammell>That's holding a shared resource.

00:49:01.540 --> 00:49:02.880
<v Chris Gammell>That's called priority inversion.

00:49:03.080 --> 00:49:04.760
<v Chris Gammell>And that's, you know, that's, that's not a good thing.

00:49:04.760 --> 00:49:06.260
<v Chris Gammell>Ah, right.

00:49:06.280 --> 00:49:10.320
<v Brian Amos>I feel like that always gets like pushed pretty early into the conversation as well.

00:49:10.340 --> 00:49:12.020
<v Brian Amos>And I'm like, well, I still don't know what priority means.

00:49:12.140 --> 00:49:12.580
<v Brian Amos>And you know what I mean?

00:49:12.580 --> 00:49:15.860
<v Brian Amos>Like, it's like, I need to just understand these simple things first.

00:49:16.020 --> 00:49:16.200
<v Brian Amos>Yes.

00:49:16.540 --> 00:49:17.900
<v Brian Amos>Uh, so, okay.

00:49:17.900 --> 00:49:22.280
<v Brian Amos>So now the vent sensor, it takes that millisecond.

00:49:22.400 --> 00:49:23.460
<v Brian Amos>It's gotten nine milliseconds.

00:49:23.460 --> 00:49:27.960
<v Brian Amos>And the, so the scheduler is like, okay, well we can go start updating the screen.

00:49:28.040 --> 00:49:28.460
<v Chris Gammell>Yep.

00:49:29.140 --> 00:49:32.360
<v Brian Amos>But the screen task is going to take 30 milliseconds.

00:49:32.660 --> 00:49:32.800
<v Brian Amos>Yep.

00:49:33.180 --> 00:49:37.860
<v Brian Amos>So like what happens not after that first nine milliseconds where it's like, okay, actually

00:49:37.860 --> 00:49:40.000
<v Brian Amos>I had to go back and check the, the vent sensor again.

00:49:40.000 --> 00:49:40.480
<v Brian Amos>Yeah.

00:49:40.940 --> 00:49:46.060
<v Chris Gammell>So, uh, the scheduler is going to, so either the scheduler is going to run, like if you

00:49:46.060 --> 00:49:48.980
<v Chris Gammell>call a delay function or whatever, right.

00:49:49.480 --> 00:49:53.200
<v Chris Gammell>Or it will update some software timers or something like that.

00:49:53.200 --> 00:49:57.620
<v Chris Gammell>Or if you, you know, it kind of depends on how you have it set up and how accurate you

00:49:57.620 --> 00:50:00.180
<v Chris Gammell>want that periodicity to be.

00:50:00.500 --> 00:50:00.980
<v Chris Gammell>Right.

00:50:01.820 --> 00:50:07.360
<v Chris Gammell>Basically there's going to be some mechanism, either a software timer that goes off or the

00:50:07.360 --> 00:50:09.980
<v Chris Gammell>scheduler, while the scheduler is controlling software.

00:50:10.000 --> 00:50:17.200
<v Chris Gammell>Timers in free RTOS, but you're going to have something wake up that high priority task

00:50:17.200 --> 00:50:19.500
<v Chris Gammell>again and say, Hey, go.

00:50:20.360 --> 00:50:20.700
<v Brian Amos>Yeah.

00:50:20.960 --> 00:50:25.140
<v Chris Gammell>You know, it could be, it could be giving a semaphore from, you know, like if you want a

00:50:25.140 --> 00:50:32.720
<v Chris Gammell>really high resolution, high fidelity timing to, to hit that, you know, that 10 minutes,

00:50:32.720 --> 00:50:38.320
<v Chris Gammell>like seconds on the dot every single time, then you probably set up a hardware timer peripheral.

00:50:38.320 --> 00:50:45.200
<v Chris Gammell>And that would, you know, just give a semaphore that your high priority task is waiting for.

00:50:45.200 --> 00:50:52.400
<v Chris Gammell>And then, so inside of the, your, your ISR for this, you know, this 10 millisecond repeated

00:50:52.400 --> 00:50:58.500
<v Chris Gammell>timer in hardware, the only job of that ISR is to just give a semaphore to this task or,

00:50:58.620 --> 00:51:00.740
<v Chris Gammell>you know, there's, there's also task notifications.

00:51:00.740 --> 00:51:07.520
<v Chris Gammell>And then the, you know, the moment that that task receives that notification or semaphore,

00:51:07.520 --> 00:51:13.900
<v Chris Gammell>it's going to, the scheduler is going to swap it in, uh, into context and then it'll, it'll

00:51:13.900 --> 00:51:14.460
<v Chris Gammell>do its thing.

00:51:15.400 --> 00:51:15.760
<v Brian Amos>Yeah.

00:51:16.260 --> 00:51:16.620
<v Brian Amos>Okay.

00:51:16.780 --> 00:51:17.340
<v Brian Amos>That's great.

00:51:17.440 --> 00:51:17.580
<v Brian Amos>Yeah.

00:51:17.760 --> 00:51:22.940
<v Brian Amos>So like if, if I had like a slow-mo camera of a screen that's updating, it's like just

00:51:22.940 --> 00:51:24.840
<v Brian Amos>rastering across for the first nine milliseconds.

00:51:24.840 --> 00:51:25.200
<v Brian Amos>Yep.

00:51:25.320 --> 00:51:30.980
<v Brian Amos>I might see a quick pause as it's going to check the sensor again, but then it would just continue.

00:51:30.980 --> 00:51:32.740
<v Brian Amos>It would effectively just continue on.

00:51:32.960 --> 00:51:33.060
<v Speaker ?>Yep.

00:51:33.400 --> 00:51:33.560
<v Chris Gammell>Yeah.

00:51:33.740 --> 00:51:34.320
<v Chris Gammell>Yeah, exactly.

00:51:34.500 --> 00:51:42.220
<v Chris Gammell>And, and the beauty of, you know, task priorities is that that's happening all the time, you

00:51:42.220 --> 00:51:43.100
<v Chris Gammell>know, no matter what.

00:51:43.140 --> 00:51:49.320
<v Chris Gammell>And it just, if, if everything is working properly, it, it, it looks like magic because things are

00:51:49.320 --> 00:51:49.880
<v Chris Gammell>just happening.

00:51:49.880 --> 00:51:50.120
<v Chris Gammell>Yeah.

00:51:50.460 --> 00:51:52.680
<v Chris Gammell>You know, it's perceived to be in parallel.

00:51:53.740 --> 00:51:54.140
<v Brian Amos>Right.

00:51:54.520 --> 00:51:58.060
<v Brian Amos>I think what's crazy to me is that this is actually what's happening on the computers we're

00:51:58.060 --> 00:51:58.620
<v Brian Amos>running right now.

00:51:58.620 --> 00:52:00.960
<v Brian Amos>I mean, obviously there's more threads and, you know, they actually, but it's not

00:52:00.980 --> 00:52:03.420
<v Brian Amos>but like, yeah, we actually have computers do this stuff too.

00:52:03.600 --> 00:52:03.760
<v Chris Gammell>Yeah.

00:52:03.900 --> 00:52:04.820
<v Chris Gammell>They, they absolutely do.

00:52:04.820 --> 00:52:05.000
<v Chris Gammell>Right.

00:52:05.340 --> 00:52:05.480
<v Chris Gammell>Yeah.

00:52:05.520 --> 00:52:10.340
<v Chris Gammell>And you have multiple, multiple processors so that it actually is happening in parallel.

00:52:10.520 --> 00:52:12.040
<v Chris Gammell>You don't have just one CPU.

00:52:13.360 --> 00:52:13.720
<v Brian Amos>Right.

00:52:14.280 --> 00:52:17.240
<v Brian Amos>But it used to, it used to be more like the embedded ones, right?

00:52:17.260 --> 00:52:19.200
<v Brian Amos>I mean, like it used to be more single thread.

00:52:19.700 --> 00:52:19.820
<v Brian Amos>Yeah.

00:52:20.260 --> 00:52:20.540
<v Chris Gammell>Yeah.

00:52:20.840 --> 00:52:21.200
<v Chris Gammell>Yeah.

00:52:21.200 --> 00:52:27.100
<v Chris Gammell>But you know, the, the thing that a lot of people forget is that modern microcontrollers,

00:52:27.280 --> 00:52:30.480
<v Chris Gammell>they can do a lot in parallel too, believe it or not, because.

00:52:30.980 --> 00:52:36.440
<v Chris Gammell>You have a lot of power buried in these hardware peripherals, right?

00:52:36.500 --> 00:52:41.640
<v Chris Gammell>So you've got hardware peripherals, you've got direct memory access controllers, DMA controllers.

00:52:42.600 --> 00:52:51.440
<v Chris Gammell>It's not that difficult to set up all of your communication to be DMA driven.

00:52:51.440 --> 00:52:58.440
<v Chris Gammell>And at the end, let's say you have like a block of 12 bytes coming back from some sensor, right?

00:52:58.980 --> 00:53:05.160
<v Chris Gammell>And it just, you know, that you're always going to get those same 12 bytes and you know, it's got sensor data in it.

00:53:05.160 --> 00:53:10.820
<v Chris Gammell>Well, you, you set up DMA with a, a transfer block size of 12.

00:53:10.820 --> 00:53:19.440
<v Chris Gammell>And whenever the DMA controller says, Hey, I've collected 12 bytes, it signals some tasks to go look at those 12 bytes.

00:53:19.440 --> 00:53:27.500
<v Chris Gammell>And that entire time, the CPU wasn't worried about collecting any of the individual bytes.

00:53:27.500 --> 00:53:30.220
<v Chris Gammell>It was off updating your pretty screen or whatever.

00:53:30.220 --> 00:53:40.300
<v Chris Gammell>So, you know, there, there are actual ways to get true parallel computing on a microcontroller, but you know, it's mainly for like communication.

00:53:40.820 --> 00:53:41.680
<v Chris Gammell>That kind of stuff.

00:53:41.780 --> 00:53:50.860
<v Chris Gammell>So it's not entirely, you know, they're, they're not as bad as single core microcontrollers or as bad as they seem, I guess.

00:53:51.240 --> 00:53:51.460
<v Brian Amos>Yeah.

00:53:51.620 --> 00:53:59.000
<v Brian Amos>But I've mentioned on the past episodes recently, I've been reading, I've been reading about a lot of like computer history at park, Xerox park and stuff like that.

00:53:59.000 --> 00:54:00.820
<v Brian Amos>And they are talking about like early computing days.

00:54:00.820 --> 00:54:02.120
<v Brian Amos>And it's like, no, no, no, they're doing it.

00:54:02.460 --> 00:54:04.520
<v Brian Amos>They're doing that time slicing directly.

00:54:04.520 --> 00:54:05.840
<v Brian Amos>You know, they're doing memory.

00:54:06.000 --> 00:54:08.020
<v Brian Amos>They're moving memory the hard way.

00:54:08.120 --> 00:54:09.120
<v Brian Amos>And it's just like, Oh boy.

00:54:09.320 --> 00:54:09.480
<v Brian Amos>Yeah.

00:54:09.660 --> 00:54:10.000
<v Brian Amos>Yeah.

00:54:10.000 --> 00:54:11.320
<v Brian Amos>So yeah, we don't have to deal with me.

00:54:11.740 --> 00:54:12.360
<v Chris Gammell>It's great.

00:54:14.220 --> 00:54:20.420
<v Brian Amos>I mean, so you said, uh, when things go right, it seems like magic and I could totally see that.

00:54:20.740 --> 00:54:23.320
<v Brian Amos>Uh, most of my stuff does not go right the first time.

00:54:23.320 --> 00:54:25.420
<v Brian Amos>So how does one troubleshoot this?

00:54:25.420 --> 00:54:30.740
<v Brian Amos>Cause I'd imagine it's a non, uh, straightforward process for troubleshooting in our toss.

00:54:31.000 --> 00:54:35.460
<v Chris Gammell>Um, well, it, you know, it kind of depends on the tools that you have at your disposal.

00:54:35.460 --> 00:54:42.340
<v Chris Gammell>One of the reasons that I like ozone a lot is, um, it is free RTOS aware.

00:54:43.180 --> 00:54:51.780
<v Chris Gammell>So, uh, meaning, you know, if you, if you pull up like a standard debugger and now there are a lot of IDs that have gotten this right.

00:54:51.780 --> 00:54:59.360
<v Chris Gammell>But years ago that you're running the mill IDE, it could only look at one stack at a time.

00:54:59.360 --> 00:55:02.400
<v Chris Gammell>That was the, you know, the, the, the processor stack.

00:55:02.400 --> 00:55:08.240
<v Chris Gammell>And that's, and, and you could step through if you have multiple tasks, you could like step through tasks and that kind of stuff.

00:55:08.880 --> 00:55:12.700
<v Chris Gammell>But you couldn't like view multiple stacks at once.

00:55:13.080 --> 00:55:13.440
<v Chris Gammell>Right.

00:55:13.480 --> 00:55:18.020
<v Chris Gammell>So you couldn't view the context of multiple tasks at the same time.

00:55:18.060 --> 00:55:19.240
<v Chris Gammell>You couldn't just hit the pause button.

00:55:19.360 --> 00:55:21.140
<v Chris Gammell>You're like, okay, well, Hey, where's my sensor task?

00:55:21.200 --> 00:55:22.520
<v Chris Gammell>Where's my UI task?

00:55:22.680 --> 00:55:24.280
<v Brian Amos>Where's, and this one's asleep.

00:55:24.360 --> 00:55:25.020
<v Brian Amos>This one's asleep.

00:55:25.100 --> 00:55:25.380
<v Chris Gammell>Exactly.

00:55:25.380 --> 00:55:29.480
<v Chris Gammell>And you can do all of that with, you know, things like ozone.

00:55:29.480 --> 00:55:34.560
<v Chris Gammell>And I think that for sure the NXP stuff has, you know, RTOS awareness.

00:55:34.880 --> 00:55:35.580
<v Chris Gammell>I imagine.

00:55:36.820 --> 00:55:38.740
<v Chris Gammell>Ozone is the SEGUR debunkers.

00:55:38.840 --> 00:55:39.060
<v Chris Gammell>Yes.

00:55:39.180 --> 00:55:40.460
<v Chris Gammell>Ozone is the SEGUR debunker.

00:55:40.580 --> 00:55:40.720
<v Chris Gammell>Yep.

00:55:41.300 --> 00:55:41.480
<v Chris Gammell>Yeah.

00:55:41.480 --> 00:55:48.560
<v Chris Gammell>And I think STM 32, their cube stuff, you know, they, they have RTOS awareness too now.

00:55:48.840 --> 00:55:48.920
<v Chris Gammell>So.

00:55:49.600 --> 00:55:49.920
<v Brian Amos>Mm-hmm.

00:55:50.680 --> 00:55:54.240
<v Brian Amos>And do they have to be aware of the specific type?

00:55:54.240 --> 00:55:59.220
<v Brian Amos>Like they have to kind of understand the paradigm that free RTOS is specifically, or is it just kind of a broad?

00:55:59.220 --> 00:55:59.300
<v Brian Amos>Yeah.

00:55:59.300 --> 00:56:06.000
<v Chris Gammell>Because they're, they're actually looking inside the, the structures, like, you know, you have task control blocks for each task and that kind of thing.

00:56:06.000 --> 00:56:11.600
<v Chris Gammell>So they're, they're actually looking at all of that to obtain stack information from what I, from what I understand.

00:56:12.320 --> 00:56:18.200
<v Chris Gammell>So, you know, it's, it's not just, it's not, you can't use any RTOS and then all of a sudden, you know, everything is magic.

00:56:18.840 --> 00:56:19.200
<v Chris Gammell>Yeah.

00:56:19.200 --> 00:56:23.920
<v Chris Gammell>You know, you have to use something that supports the, the RTOS that you're using specifically.

00:56:23.920 --> 00:56:24.360
<v Chris Gammell>Yeah.

00:56:25.260 --> 00:56:25.540
<v Chris Gammell>Yeah.

00:56:25.540 --> 00:56:34.380
<v Chris Gammell>So there's, so there's that, and you can, you know, be able to hit a pause button and, and get some insight as to what task is currently running, which ones are in the block state.

00:56:34.380 --> 00:56:40.140
<v Chris Gammell>You know, you, you wind up being able to dive into a stack of each task very easily.

00:56:40.480 --> 00:56:45.500
<v Chris Gammell>You know, just, you know, unwind stacks and that kind of stuff and see local variables and all that.

00:56:45.500 --> 00:56:47.900
<v Chris Gammell>So you get all that for free.

00:56:48.180 --> 00:57:03.940
<v Chris Gammell>And then if you wind up running into really interesting problems with, you know, tasks not completing or a task is seemingly never running, you know, it's, it's, it's starved for resources, that kind of stuff.

00:57:04.100 --> 00:57:07.140
<v Chris Gammell>In that case, there's, there are a couple of different products.

00:57:07.140 --> 00:57:16.800
<v Chris Gammell>So Sager makes something called system view, system viewer, and it basically gives you a graphical representation of which tasks are running.

00:57:17.100 --> 00:57:17.200
<v Brian Amos>Yeah.

00:57:18.020 --> 00:57:19.200
<v Chris Gammell>And their priority.

00:57:19.200 --> 00:57:22.000
<v Chris Gammell>And, you know, it's just all laid out very nicely.

00:57:23.120 --> 00:57:28.780
<v Chris Gammell>There's another product called Persefio Tracelizer, I believe.

00:57:30.120 --> 00:57:31.360
<v Brian Amos>God, that's a terrible name.

00:57:32.080 --> 00:57:32.300
<v Brian Amos>Yeah.

00:57:32.500 --> 00:57:32.720
<v Brian Amos>Yeah.

00:57:32.720 --> 00:57:36.960
<v Brian Amos>And I think that's like, has it been around a long time?

00:57:37.000 --> 00:57:38.000
<v Brian Amos>Cause it sounds like a long time.

00:57:38.380 --> 00:57:44.020
<v Chris Gammell>I'm not sure how long, I mean, I, I've, I'm trying to think I first found out about them and.

00:57:45.480 --> 00:57:45.880
<v Brian Amos>Sorry.

00:57:45.940 --> 00:57:47.240
<v Brian Amos>If you work there, I'm sorry.

00:57:47.360 --> 00:57:53.320
<v Brian Amos>I just, I, I have, uh, you know, dislike for many, many names of things.

00:57:53.380 --> 00:57:56.180
<v Brian Amos>You know, it's like we're letting engineers name a lot of things.

00:57:56.180 --> 00:57:58.240
<v Brian Amos>And as an engineer, I'm still offended.

00:57:58.800 --> 00:57:59.200
<v Chris Gammell>Yeah.

00:57:59.360 --> 00:57:59.540
<v Chris Gammell>Yeah.

00:58:00.540 --> 00:58:01.960
<v Chris Gammell>Likely named by an engineer.

00:58:01.960 --> 00:58:04.000
<v Brian Amos>Um, yeah, it's fine.

00:58:04.200 --> 00:58:08.120
<v Chris Gammell>On the upside, you know, they, you know, I guess you could say that they probably didn't

00:58:08.120 --> 00:58:11.080
<v Chris Gammell>put a whole lot of money into the marketing department.

00:58:11.300 --> 00:58:11.480
<v Chris Gammell>That's true.

00:58:11.580 --> 00:58:12.340
<v Chris Gammell>They focused on.

00:58:12.340 --> 00:58:12.560
<v Chris Gammell>That's right.

00:58:12.760 --> 00:58:13.820
<v Brian Amos>They're not wasting money.

00:58:13.940 --> 00:58:14.840
<v Chris Gammell>They're pouring it back.

00:58:14.840 --> 00:58:16.960
<v Chris Gammell>That's how you wind up with names like that.

00:58:18.560 --> 00:58:20.880
<v Chris Gammell>Or, you know, it was trendy in the nineties or whatever.

00:58:20.980 --> 00:58:21.560
<v Chris Gammell>I don't know how.

00:58:21.860 --> 00:58:21.960
<v Chris Gammell>Yeah.

00:58:21.960 --> 00:58:22.940
<v Chris Gammell>That's what I was really figuring.

00:58:23.140 --> 00:58:23.260
<v Chris Gammell>Yeah.

00:58:23.400 --> 00:58:23.620
<v Chris Gammell>Yeah.

00:58:23.680 --> 00:58:24.420
<v Chris Gammell>I have no idea.

00:58:25.100 --> 00:58:26.440
<v Chris Gammell>But you know, same kind of thing.

00:58:26.440 --> 00:58:27.920
<v Chris Gammell>And that's, that's actually a little bit easier.

00:58:27.920 --> 00:58:31.620
<v Chris Gammell>It's way easier to get set up with Tracelizer than, than system view.

00:58:31.620 --> 00:58:32.060
<v Chris Gammell>Yeah.

00:58:32.060 --> 00:58:34.140
<v Chris Gammell>For free RTOS, because it's just directly.

00:58:34.140 --> 00:58:39.780
<v Chris Gammell>So free RTOS has all these trace hooks built into it and you actually have to go in and

00:58:39.780 --> 00:58:44.160
<v Chris Gammell>like, you have to kind of manually patch in a bunch of stuff.

00:58:44.300 --> 00:58:45.000
<v Chris Gammell>Tell what it is.

00:58:45.220 --> 00:58:46.080
<v Chris Gammell>And yeah.

00:58:46.080 --> 00:58:46.120
<v Chris Gammell>Yeah.

00:58:46.240 --> 00:58:50.620
<v Chris Gammell>For, for system view, but Tracelizer just kind of works out of the box, which is awesome.

00:58:51.060 --> 00:58:51.740
<v Chris Gammell>It's very pretty.

00:58:52.460 --> 00:58:56.900
<v Chris Gammell>You can, you can just see, you know, which tasks are running, which ones are interrupting

00:58:56.900 --> 00:58:57.440
<v Chris Gammell>others.

00:58:57.440 --> 00:59:04.240
<v Chris Gammell>And they give you statistics on, you know, all the tasks, how long they've been in the

00:59:04.240 --> 00:59:05.560
<v Chris Gammell>block state, that kind of stuff.

00:59:05.560 --> 00:59:06.760
<v Brian Amos>Mm-hmm.

00:59:07.000 --> 00:59:07.120
<v Chris Gammell>Yeah.

00:59:07.120 --> 00:59:13.760
<v Chris Gammell>And at least with system viewer, they also, you can also effectively tie like a really

00:59:13.760 --> 00:59:21.160
<v Chris Gammell>efficient printf debug that gets automatically timestamped and cross correlated with the real

00:59:21.160 --> 00:59:23.480
<v Chris Gammell>time graphing of all this stuff.

00:59:23.480 --> 00:59:26.320
<v Chris Gammell>So that winds up being super helpful too.

00:59:26.660 --> 00:59:33.380
<v Chris Gammell>So, you know, you, if you, if you need to orient yourself, you can give yourself little, little

00:59:33.380 --> 00:59:38.780
<v Chris Gammell>printf breadcrumbs in different tasks and then you can kind of cross correlate things

00:59:38.780 --> 00:59:39.960
<v Chris Gammell>temporarily that way.

00:59:41.060 --> 00:59:41.500
<v Brian Amos>Yeah.

00:59:41.800 --> 00:59:43.740
<v Brian Amos>So you have a really good on page.

00:59:43.820 --> 00:59:48.260
<v Brian Amos>So people that are following along on page 48, which I think is chapter two.

00:59:48.680 --> 00:59:49.500
<v Brian Amos>I'm not sure.

00:59:49.500 --> 00:59:54.020
<v Brian Amos>Page 48 though, you have a realistic task setup and preemptive scheduler.

00:59:54.260 --> 00:59:59.120
<v Brian Amos>And like, this is what I imagine I would want most things to look like.

00:59:59.180 --> 01:00:00.760
<v Brian Amos>It basically is a graphical representation.

01:00:01.340 --> 01:00:04.620
<v Brian Amos>People are looking, if they're looking at this with their mind or their ears right now,

01:00:04.780 --> 01:00:07.620
<v Brian Amos>they would basically see like how many times the task is run.

01:00:07.800 --> 01:00:13.880
<v Brian Amos>And then like, as the task gets sliced up and then like the scheduler being part of the

01:00:13.880 --> 01:00:15.280
<v Brian Amos>task as well, because it does take time.

01:00:15.340 --> 01:00:18.860
<v Brian Amos>The schedule has to take time to like feel like what's next and figure that stuff out.

01:00:18.860 --> 01:00:19.180
<v Brian Amos>Yeah.

01:00:19.540 --> 01:00:19.860
<v Chris Gammell>Yeah.

01:00:19.860 --> 01:00:24.500
<v Chris Gammell>And when you're using these tools, this is actually like one of the views that you have.

01:00:24.860 --> 01:00:25.300
<v Chris Gammell>Right.

01:00:25.340 --> 01:00:31.920
<v Chris Gammell>So this is, this is what shows up on, you know, on page 48 is, Hey, look, here's, here's

01:00:31.920 --> 01:00:35.660
<v Chris Gammell>everything that ran and, you know, here's why it couldn't run.

01:00:37.360 --> 01:00:38.140
<v Brian Amos>Yeah, exactly.

01:00:38.320 --> 01:00:38.680
<v Brian Amos>Exactly.

01:00:38.860 --> 01:00:42.580
<v Brian Amos>And like, I think the, so now I'm a little confused again with priority.

01:00:42.700 --> 01:00:44.500
<v Brian Amos>So if priority is going up.

01:00:44.500 --> 01:00:44.740
<v Brian Amos>Yeah.

01:00:44.740 --> 01:00:47.980
<v Chris Gammell>This is not Cortex M priorities, which are inverted.

01:00:48.980 --> 01:00:54.480
<v Chris Gammell>So, so higher priority is more important in, in, in this world.

01:00:55.760 --> 01:00:56.160
<v Chris Gammell>Okay.

01:00:56.340 --> 01:00:56.660
<v Chris Gammell>All right.

01:00:56.740 --> 01:00:58.220
<v Chris Gammell>So it makes more sense to me.

01:00:58.220 --> 01:01:04.680
<v Chris Gammell>Cortex M priorities lower is more important, but that's not, that's not the case for, for.

01:01:05.180 --> 01:01:05.620
<v Chris Gammell>Yeah.

01:01:05.660 --> 01:01:11.000
<v Brian Amos>Cause is Cortex M the one that also goes negative as well when you need to like really do crazy

01:01:11.000 --> 01:01:11.920
<v Brian Amos>important stuff.

01:01:12.820 --> 01:01:13.140
<v Chris Gammell>Yeah.

01:01:13.220 --> 01:01:15.820
<v Chris Gammell>I mean, you have like non-maskable interrupts and that kind of stuff too.

01:01:16.000 --> 01:01:16.100
<v Chris Gammell>So.

01:01:16.360 --> 01:01:17.260
<v Chris Gammell>Ah, yeah.

01:01:17.500 --> 01:01:17.720
<v Brian Amos>Okay.

01:01:18.560 --> 01:01:19.280
<v Chris Gammell>I'm not sure.

01:01:19.420 --> 01:01:23.760
<v Chris Gammell>I don't know if it starts at zero or if there's a negative number off the top of my head.

01:01:24.940 --> 01:01:25.300
<v Chris Gammell>Yeah.

01:01:25.620 --> 01:01:25.900
<v Brian Amos>Yeah.

01:01:26.100 --> 01:01:26.340
<v Brian Amos>Okay.

01:01:26.900 --> 01:01:32.140
<v Brian Amos>I feel like generally this graph is, is very useful to see here because it's, and stuff

01:01:32.140 --> 01:01:35.240
<v Brian Amos>like this where it's showing like some things are, some, some of the bigger tasks are getting

01:01:35.240 --> 01:01:36.880
<v Brian Amos>split up and anything.

01:01:36.880 --> 01:01:40.400
<v Brian Amos>And so in, yeah, I guess I certain people should get the book.

01:01:40.660 --> 01:01:41.760
<v Brian Amos>Maybe we can screen.

01:01:41.840 --> 01:01:43.700
<v Brian Amos>It looks like you have a CC attribution.

01:01:43.780 --> 01:01:45.520
<v Brian Amos>Maybe we can drop this into the show notes as well.

01:01:45.720 --> 01:01:46.120
<v Chris Gammell>Yeah, absolutely.

01:01:46.240 --> 01:01:46.400
<v Chris Gammell>Yeah.

01:01:46.460 --> 01:01:52.980
<v Chris Gammell>All the images, all the images in the book with the exception of one image that I got permission

01:01:52.980 --> 01:01:55.720
<v Chris Gammell>from ST to use of the, of the dev board used in the book.

01:01:55.800 --> 01:01:57.620
<v Chris Gammell>They're all, you know, it's all creative commons.

01:01:57.740 --> 01:01:59.320
<v Chris Gammell>So you use them as you see fit.

01:01:59.720 --> 01:02:00.080
<v Chris Gammell>All right.

01:02:00.620 --> 01:02:02.120
<v Brian Amos>We got some art for the show now too.

01:02:02.220 --> 01:02:02.620
<v Chris Gammell>That's great.

01:02:02.680 --> 01:02:03.160
<v Chris Gammell>Oh boy.

01:02:03.340 --> 01:02:04.140
<v Chris Gammell>As long as you have attribution.

01:02:04.140 --> 01:02:04.780
<v Brian Amos>Yeah.

01:02:06.620 --> 01:02:07.020
<v Chris Gammell>Yeah.

01:02:07.240 --> 01:02:08.760
<v Chris Gammell>CC by so.

01:02:08.960 --> 01:02:09.100
<v Brian Amos>Yeah.

01:02:09.460 --> 01:02:09.660
<v Chris Gammell>Yeah.

01:02:09.660 --> 01:02:10.120
<v Chris Gammell>Remix them.

01:02:10.200 --> 01:02:11.980
<v Chris Gammell>And there's, I mean, you can even get the source.

01:02:12.160 --> 01:02:14.260
<v Chris Gammell>These were all done with draw.io.

01:02:14.920 --> 01:02:15.600
<v Chris Gammell>So, you know.

01:02:15.660 --> 01:02:15.940
<v Chris Gammell>Oh, cool.

01:02:16.120 --> 01:02:17.520
<v Chris Gammell>You can, yeah, it's awesome.

01:02:18.020 --> 01:02:25.920
<v Chris Gammell>So, you know, it's the, the PNG there's my, I think my personal GitHub repo has like

01:02:25.920 --> 01:02:28.020
<v Chris Gammell>RTOS images or something like that.

01:02:28.020 --> 01:02:34.980
<v Chris Gammell>So they're all in there as PNGs and they have the embedded draw.io source inside of the image.

01:02:36.280 --> 01:02:36.400
<v Brian Amos>Okay.

01:02:36.720 --> 01:02:36.980
<v Brian Amos>Great.

01:02:37.180 --> 01:02:37.360
<v Brian Amos>Great.

01:02:37.920 --> 01:02:40.780
<v Brian Amos>So scrolling through this book, like I said, I highly recommend this book.

01:02:41.360 --> 01:02:47.320
<v Brian Amos>Scrolling through to page 98, you show digi-key, a digi-key window and you show a bunch of

01:02:47.320 --> 01:02:49.180
<v Brian Amos>STM 32 parts being available.

01:02:49.840 --> 01:02:51.400
<v Brian Amos>What universe is this in?

01:02:51.860 --> 01:02:54.260
<v Brian Amos>Well, this book was written in 1995.

01:02:54.260 --> 01:02:56.440
<v Chris Gammell>I used bubblegum tap shoes.

01:02:58.440 --> 01:02:59.620
<v Chris Gammell>He knows the code word.

01:03:00.400 --> 01:03:09.860
<v Chris Gammell>So I checked yesterday and Mouser actually had 32, 32 of the dev boards, the, the, the

01:03:09.860 --> 01:03:11.140
<v Chris Gammell>nucleo board that's used.

01:03:11.260 --> 01:03:11.960
<v Chris Gammell>Dev boards.

01:03:12.380 --> 01:03:13.060
<v Chris Gammell>No, no chips.

01:03:13.160 --> 01:03:13.520
<v Chris Gammell>I don't know.

01:03:13.520 --> 01:03:14.800
<v Chris Gammell>Dev boards you can use other chips.

01:03:14.800 --> 01:03:15.780
<v Chris Gammell>I don't have chips, but yeah.

01:03:16.520 --> 01:03:16.720
<v Chris Gammell>Yeah.

01:03:16.900 --> 01:03:20.320
<v Brian Amos>We're trying to get people through the content here, not the, not, not to be able to build

01:03:20.320 --> 01:03:21.100
<v Brian Amos>a thing at the end.

01:03:21.100 --> 01:03:25.120
<v Chris Gammell>Well, you know, I mean this, to be fair, this was, this came out in 2020.

01:03:26.120 --> 01:03:26.940
<v Chris Gammell>But it's true.

01:03:27.160 --> 01:03:27.280
<v Chris Gammell>Yeah.

01:03:27.420 --> 01:03:33.040
<v Chris Gammell>You know, but it was written in 2019 and then it was just like finished up.

01:03:33.420 --> 01:03:33.780
<v Chris Gammell>Yeah.

01:03:34.160 --> 01:03:34.520
<v Chris Gammell>Yeah.

01:03:34.520 --> 01:03:36.600
<v Chris Gammell>We didn't have to write in time for people to be locked in.

01:03:37.000 --> 01:03:37.400
<v Brian Amos>Yep.

01:03:37.600 --> 01:03:37.760
<v Brian Amos>Yep.

01:03:38.100 --> 01:03:40.480
<v Brian Amos>Well, a lot of the, so you have exercises in the book.

01:03:40.840 --> 01:03:43.420
<v Brian Amos>It's all based on the nucleo F seven.

01:03:43.680 --> 01:03:45.880
<v Brian Amos>The, I remember it's got the ethernet port on it.

01:03:45.940 --> 01:03:47.420
<v Brian Amos>That's what is important to me.

01:03:47.880 --> 01:03:48.160
<v Brian Amos>Yes.

01:03:48.160 --> 01:03:48.560
<v Brian Amos>Yeah.

01:03:48.760 --> 01:03:48.980
<v Chris Gammell>Yeah.

01:03:49.080 --> 01:03:53.580
<v Chris Gammell>So you have a nucleo F seven for all the exercises.

01:03:53.580 --> 01:03:58.800
<v Chris Gammell>And the cool part about that is one of the reasons for choosing that board is that you

01:03:58.800 --> 01:04:01.880
<v Chris Gammell>can actually reef that has an onboard programmer on it.

01:04:01.880 --> 01:04:02.160
<v Chris Gammell>Right.

01:04:02.220 --> 01:04:04.160
<v Chris Gammell>So an ST link V two.

01:04:04.260 --> 01:04:04.540
<v Chris Gammell>Right.

01:04:05.020 --> 01:04:13.060
<v Chris Gammell>And you can actually go through and reflash the firmware that runs on that ST link and

01:04:13.060 --> 01:04:14.500
<v Chris Gammell>make it look like a J link.

01:04:14.940 --> 01:04:15.240
<v Brian Amos>Yeah.

01:04:15.240 --> 01:04:19.220
<v Chris Gammell>So Sager has, and there are instructions on how to do that both on Sager's website.

01:04:19.220 --> 01:04:23.040
<v Chris Gammell>And, you know, I think I probably just put a link in the, in the actual text of the book

01:04:23.040 --> 01:04:27.920
<v Chris Gammell>there, but so it winds up looking like a J link rather than an ST link.

01:04:27.920 --> 01:04:32.400
<v Chris Gammell>So you can use all the sacred tooling on like a trial basis for non-commercial kind of stuff,

01:04:32.600 --> 01:04:34.720
<v Chris Gammell>which is, which is a neat feature.

01:04:34.940 --> 01:04:38.900
<v Brian Amos>And that then enables things like system view and ozone or is it just.

01:04:39.520 --> 01:04:39.740
<v Brian Amos>Okay.

01:04:39.940 --> 01:04:40.260
<v Brian Amos>All right.

01:04:40.260 --> 01:04:40.620
<v Brian Amos>Yeah.

01:04:41.140 --> 01:04:41.500
<v Brian Amos>Yeah.

01:04:41.560 --> 01:04:42.100
<v Brian Amos>That's nice.

01:04:42.600 --> 01:04:42.820
<v Brian Amos>Yeah.

01:04:42.980 --> 01:04:43.200
<v Brian Amos>Yeah.

01:04:43.240 --> 01:04:47.880
<v Chris Gammell>So, you know, you wind up with like this, you know, effectively a professional grade debug

01:04:47.880 --> 01:04:52.780
<v Chris Gammell>set up, you know, just with a dev board only, which is awesome.

01:04:53.220 --> 01:04:56.200
<v Brian Amos>I have, I have a $600 Sager programmer, J link.

01:04:56.460 --> 01:04:56.740
<v Chris Gammell>Yes.

01:04:57.020 --> 01:04:57.200
<v Brian Amos>Yeah.

01:04:57.860 --> 01:04:59.200
<v Brian Amos>And I didn't need it.

01:04:59.280 --> 01:04:59.700
<v Brian Amos>Apparently.

01:05:00.240 --> 01:05:00.600
<v Chris Gammell>Yeah.

01:05:00.660 --> 01:05:00.940
<v Chris Gammell>Yep.

01:05:01.200 --> 01:05:01.580
<v Chris Gammell>Yeah.

01:05:01.580 --> 01:05:02.440
<v Chris Gammell>You don't, you don't need it.

01:05:02.500 --> 01:05:03.020
<v Chris Gammell>Not for this.

01:05:03.060 --> 01:05:05.820
<v Chris Gammell>I mean, you know, the, the minute you make your own board.

01:05:06.520 --> 01:05:07.040
<v Brian Amos>That's right.

01:05:07.080 --> 01:05:07.960
<v Chris Gammell>That's the reason I bought it.

01:05:08.240 --> 01:05:08.440
<v Chris Gammell>Yeah.

01:05:08.440 --> 01:05:08.920
<v Chris Gammell>Yeah.

01:05:09.320 --> 01:05:09.680
<v Chris Gammell>Yeah.

01:05:10.300 --> 01:05:10.480
<v Chris Gammell>Yeah.

01:05:10.560 --> 01:05:13.400
<v Chris Gammell>Don't, don't put, don't put dev boards into products.

01:05:14.020 --> 01:05:14.680
<v Chris Gammell>Don't do it.

01:05:14.680 --> 01:05:14.900
<v Chris Gammell>That's right.

01:05:15.360 --> 01:05:16.980
<v Chris Gammell>As tempting as it may be.

01:05:17.280 --> 01:05:18.040
<v Brian Amos>It's bad.

01:05:18.160 --> 01:05:18.560
<v Brian Amos>It's bad.

01:05:20.240 --> 01:05:24.900
<v Brian Amos>So if people are going through the book, then what should they expect to learn kind of by

01:05:24.900 --> 01:05:25.260
<v Brian Amos>the end?

01:05:25.320 --> 01:05:27.620
<v Brian Amos>Like, I mean, there's different chapters, there's different topics, obviously.

01:05:28.220 --> 01:05:31.540
<v Brian Amos>Is it like, should someone be able to build an entire system by the end?

01:05:31.580 --> 01:05:33.840
<v Brian Amos>Or is it more kind of a piece by piece?

01:05:34.100 --> 01:05:35.160
<v Chris Gammell>So it depends on your background.

01:05:35.160 --> 01:05:41.340
<v Chris Gammell>Like there is no, so it, it, like, I think chapter 13, that's where everything kind of

01:05:41.340 --> 01:05:42.360
<v Chris Gammell>gets pulled together.

01:05:43.020 --> 01:05:47.100
<v Chris Gammell>And there's a little, like a little project that blinks an led.

01:05:47.100 --> 01:05:56.860
<v Chris Gammell>So it, it has USB connectivity to your computer and it's got like this little Python UI and it's

01:05:56.860 --> 01:05:57.660
<v Chris Gammell>got a couple of buttons.

01:05:57.660 --> 01:06:04.680
<v Chris Gammell>So the, the discovery board has a few LEDs on it and you can control the brightness of each LED

01:06:04.680 --> 01:06:07.220
<v Chris Gammell>with little sliders on the UI.

01:06:07.220 --> 01:06:13.000
<v Chris Gammell>And that, that kind of chugs through building up this message and there's a, you know, there's a

01:06:13.000 --> 01:06:17.080
<v Chris Gammell>message receiver and then there's a couple of different tasks they're running to control

01:06:17.080 --> 01:06:17.600
<v Chris Gammell>these LEDs.

01:06:17.600 --> 01:06:24.520
<v Chris Gammell>So, you know, if you, if you actually follow through up to that point, at least then, you

01:06:24.520 --> 01:06:28.360
<v Chris Gammell>know, yeah, you can, you can get started that as soon.

01:06:28.480 --> 01:06:35.880
<v Chris Gammell>So what, one of the things that, that this doesn't do is, you know, it, it starts out

01:06:35.880 --> 01:06:37.040
<v Chris Gammell>with a code base.

01:06:37.040 --> 01:06:43.160
<v Chris Gammell>So I think, you know, you get like several dozen pre-configured projects and configurations

01:06:43.160 --> 01:06:45.540
<v Chris Gammell>inside of projects for STM cube.

01:06:45.540 --> 01:06:52.500
<v Chris Gammell>So like you, you, you clone the repo and then you just import it into STM 3D cube.

01:06:52.980 --> 01:06:55.000
<v Chris Gammell>And, you know, it's effectively just an eclipse ID.

01:06:55.000 --> 01:06:55.360
<v Chris Gammell>Right.

01:06:55.600 --> 01:06:59.420
<v Chris Gammell>And then all of a sudden you have, you have access to all these examples, you know?

01:06:59.480 --> 01:07:03.620
<v Chris Gammell>So, so if you start from any one of those examples, it's really designed so that you

01:07:03.620 --> 01:07:08.240
<v Chris Gammell>can play with the examples, break stuff and see.

01:07:08.240 --> 01:07:09.220
<v Chris Gammell>It's totally the right way to do it.

01:07:09.300 --> 01:07:10.380
<v Chris Gammell>Like how it broke.

01:07:10.760 --> 01:07:12.940
<v Chris Gammell>So you have this sandbox to start from.

01:07:12.940 --> 01:07:18.740
<v Chris Gammell>So what, what it doesn't do is it, it in, I don't think anywhere in the, in the text,

01:07:18.740 --> 01:07:27.400
<v Chris Gammell>does it take you through like, okay, now open the ID and select the discovery F7 board and

01:07:27.400 --> 01:07:29.080
<v Chris Gammell>select free RTOS.

01:07:29.180 --> 01:07:36.300
<v Chris Gammell>And honestly, like that, a lot of that stuff changes so quickly that you're anything in

01:07:36.300 --> 01:07:38.020
<v Chris Gammell>print isn't going to be able to keep up with it.

01:07:38.380 --> 01:07:39.060
<v Chris Gammell>Most likely.

01:07:39.640 --> 01:07:43.920
<v Brian Amos>I mean, even YouTube, like I, I find YouTube videos and I'm like this, this tool, this tool

01:07:43.920 --> 01:07:45.000
<v Brian Amos>chain is completely different now.

01:07:45.360 --> 01:07:45.520
<v Chris Gammell>Yeah.

01:07:45.880 --> 01:07:50.200
<v Chris Gammell>That's the crazy part is that like, you know, with a lot of this stuff, they have all these

01:07:50.200 --> 01:07:51.820
<v Chris Gammell>silicon manufacturers.

01:07:51.980 --> 01:07:57.260
<v Chris Gammell>They're, they're coming out with all these really cool tools for configuration, but it's

01:07:57.260 --> 01:07:59.300
<v Chris Gammell>very difficult to use them long-term.

01:07:59.300 --> 01:08:03.340
<v Chris Gammell>If you have a long running project that needs to be supported, you know, you, you wind up

01:08:03.340 --> 01:08:11.480
<v Chris Gammell>either needing to kind of divorce yourself from the, from the actual like setup portion

01:08:11.480 --> 01:08:14.980
<v Chris Gammell>of it and like, just make a, an archive of the project.

01:08:14.980 --> 01:08:15.320
<v Chris Gammell>Right.

01:08:15.340 --> 01:08:20.460
<v Chris Gammell>And then just deal with the actual source that matters because, you know, in five years, you're,

01:08:20.500 --> 01:08:25.380
<v Chris Gammell>you're not going to be able to like add in another GPIO line that you need to access or

01:08:25.380 --> 01:08:32.940
<v Chris Gammell>reconfigure this extra spy, you know, this extra peripheral for, to do whatever task using

01:08:32.940 --> 01:08:36.240
<v Chris Gammell>the old project with the new IDE, right?

01:08:36.480 --> 01:08:39.000
<v Chris Gammell>Like it's just, it's, it's moving too quickly.

01:08:39.000 --> 01:08:46.320
<v Chris Gammell>So importing source, knock on wood that, that process changes much more slowly, thankfully.

01:08:47.000 --> 01:08:47.080
<v Brian Amos>Yeah.

01:08:47.500 --> 01:08:47.700
<v Brian Amos>Yeah.

01:08:47.940 --> 01:08:48.120
<v Brian Amos>Yep.

01:08:48.480 --> 01:08:48.660
<v Brian Amos>So.

01:08:49.160 --> 01:08:49.560
<v Brian Amos>Right.

01:08:49.600 --> 01:08:52.800
<v Brian Amos>I think it's just then when you do need to dig through all the registers that set things

01:08:52.800 --> 01:08:57.320
<v Brian Amos>up and whatever, you either need to start from a project like you were offering here, or

01:08:57.320 --> 01:09:03.120
<v Brian Amos>you need to be prepared for some time with the reference manual and really making sure

01:09:03.120 --> 01:09:03.740
<v Brian Amos>things are right.

01:09:04.000 --> 01:09:04.120
<v Chris Gammell>Yeah.

01:09:04.160 --> 01:09:05.900
<v Chris Gammell>Well, and that's the, that's the strong point.

01:09:05.960 --> 01:09:07.480
<v Chris Gammell>A lot of these ideas too, right?

01:09:07.520 --> 01:09:09.480
<v Chris Gammell>Is that they're very good.

01:09:09.740 --> 01:09:16.060
<v Chris Gammell>Well, some of them, NXP more so, I think they're, they're very good at creating like

01:09:16.060 --> 01:09:19.040
<v Chris Gammell>a workable starting point.

01:09:19.040 --> 01:09:19.840
<v Brian Amos>Mm-hmm.

01:09:20.160 --> 01:09:26.880
<v Chris Gammell>But after you get that initial setup, I, you know, my normal workflow is okay, look,

01:09:26.980 --> 01:09:30.060
<v Chris Gammell>I've got, I know what registers to tickle.

01:09:30.140 --> 01:09:31.860
<v Chris Gammell>I know what bits in the registers and all that.

01:09:31.940 --> 01:09:32.560
<v Chris Gammell>Okay, fine.

01:09:32.980 --> 01:09:38.920
<v Chris Gammell>Let's bring all that in and make it, you know, let's make it our own and then put an interface.

01:09:39.180 --> 01:09:39.200
<v Chris Gammell>Right.

01:09:39.200 --> 01:09:41.100
<v Brian Amos>And I'm never touching cube again for this project, right?

01:09:41.220 --> 01:09:41.520
<v Brian Amos>Exactly.

01:09:41.720 --> 01:09:41.960
<v Chris Gammell>Yes.

01:09:42.140 --> 01:09:42.360
<v Chris Gammell>Yeah.

01:09:42.360 --> 01:09:45.840
<v Chris Gammell>And, and I've, you know, I've talked with engineers, other engineers are like, oh, how

01:09:45.840 --> 01:09:48.640
<v Chris Gammell>do you get cube to, to play nice with your code?

01:09:48.660 --> 01:09:50.480
<v Chris Gammell>I'm like, you don't.

01:09:51.240 --> 01:09:51.560
<v Chris Gammell>Yeah.

01:09:52.200 --> 01:09:53.060
<v Brian Amos>No, I feel, yeah.

01:09:53.140 --> 01:09:53.800
<v Brian Amos>I've done the same thing.

01:09:53.800 --> 01:09:57.100
<v Brian Amos>And it's like, if I really then, if I'm like, okay, well, I really need to reconfigure this,

01:09:57.140 --> 01:09:57.300
<v Brian Amos>whatever.

01:09:57.360 --> 01:09:59.340
<v Brian Amos>It's like, start a new project with cube.

01:09:59.540 --> 01:09:59.780
<v Chris Gammell>Yeah.

01:10:00.420 --> 01:10:03.240
<v Brian Amos>Make it output the stuff and then do a diff between the two files.

01:10:03.280 --> 01:10:04.880
<v Brian Amos>Just be like, oh yeah, that's different there.

01:10:04.880 --> 01:10:05.120
<v Brian Amos>Yeah.

01:10:05.120 --> 01:10:05.360
<v Brian Amos>Exactly.

01:10:05.480 --> 01:10:05.680
<v Brian Amos>Yeah.

01:10:05.680 --> 01:10:11.100
<v Chris Gammell>And then, you know, if you do that enough, eventually you start finding similarities and you're like, okay,

01:10:11.100 --> 01:10:16.260
<v Chris Gammell>I need to, I want to change the mode of this GPIO line, for example.

01:10:16.420 --> 01:10:17.240
<v Chris Gammell>I do this a lot.

01:10:17.340 --> 01:10:20.960
<v Chris Gammell>Well, you can actually just create, create your own abstraction for it.

01:10:20.960 --> 01:10:21.180
<v Chris Gammell>Right.

01:10:21.240 --> 01:10:25.500
<v Chris Gammell>And then, you know, at that point it's, you know, now you're, you're starting to think

01:10:25.500 --> 01:10:27.720
<v Chris Gammell>like a software engineer rather than a hardware engineer.

01:10:27.720 --> 01:10:31.600
<v Chris Gammell>And, you know, like, how can I make my own life easier down, down the road?

01:10:32.040 --> 01:10:32.440
<v Chris Gammell>Right.

01:10:32.500 --> 01:10:32.660
<v Chris Gammell>Yeah.

01:10:32.660 --> 01:10:33.520
<v Chris Gammell>But that's right.

01:10:33.560 --> 01:10:38.120
<v Brian Amos>I feel like that is probably the best of both worlds too, because it, or the best solution

01:10:38.120 --> 01:10:43.320
<v Brian Amos>for people in your, and sort of my scenarios where it's just like, you still have the under

01:10:43.320 --> 01:10:47.520
<v Brian Amos>the hood control versus like, you know, being handed a bunch of hardware abstraction layers

01:10:47.520 --> 01:10:49.380
<v Brian Amos>and you just don't know what's happening.

01:10:49.380 --> 01:10:53.740
<v Brian Amos>And you're just like, well, boy, I hope this ADC gives me a reading back when at some point,

01:10:53.800 --> 01:10:56.740
<v Brian Amos>you know, or, you know, boy, I hope that GPIO eventually goes on.

01:10:56.740 --> 01:10:57.220
<v Chris Gammell>Yeah.

01:10:57.400 --> 01:11:02.560
<v Chris Gammell>And some of them are terrifying because they'll, you know, depending on what you wind up with,

01:11:02.800 --> 01:11:04.520
<v Chris Gammell>you know, they're doing stuff inside of interrupt.

01:11:04.660 --> 01:11:11.140
<v Chris Gammell>Like they, there's some, some cases where they're literally delay functions called inside of ISRs

01:11:11.140 --> 01:11:12.500
<v Chris Gammell>and some, in some of this stuff.

01:11:13.520 --> 01:11:14.660
<v Chris Gammell>See, I know that's bad.

01:11:15.160 --> 01:11:15.640
<v Chris Gammell>Yeah.

01:11:15.800 --> 01:11:19.040
<v Chris Gammell>It's, it's, I mean, you can't always avoid it if you're waiting.

01:11:19.200 --> 01:11:25.660
<v Chris Gammell>So if you're in a tight loop, like, you know, waiting for, uh, you know, like the last bit

01:11:25.660 --> 01:11:29.800
<v Chris Gammell>of, of a bite to come in or whatever, right?

01:11:29.800 --> 01:11:34.000
<v Chris Gammell>Like, Hey, you've got something in your received buffer and, or I've got something going out

01:11:34.000 --> 01:11:34.940
<v Chris Gammell>of my transmit buffer.

01:11:35.040 --> 01:11:37.080
<v Chris Gammell>Now I need to pull and wait until it's complete.

01:11:37.520 --> 01:11:42.940
<v Chris Gammell>Like, okay, that's one thing, but finding out that you're delaying 20 milliseconds while

01:11:42.940 --> 01:11:48.960
<v Chris Gammell>you wait for an ADC to warm up between, before you take a reading, like, Oh no, you're in

01:11:48.960 --> 01:11:49.980
<v Chris Gammell>an ISR context.

01:11:50.560 --> 01:11:51.140
<v Chris Gammell>Oh geez.

01:11:51.320 --> 01:11:51.880
<v Chris Gammell>That's not good.

01:11:52.400 --> 01:11:53.040
<v Chris Gammell>Can't do that.

01:11:53.480 --> 01:11:53.640
<v Brian Amos>Yeah.

01:11:53.640 --> 01:11:55.020
<v Brian Amos>It just blocks, blocks at all.

01:11:55.100 --> 01:11:55.220
<v Brian Amos>Huh?

01:11:55.360 --> 01:12:00.060
<v Brian Amos>Just hope you're, hope you're, uh, your overall system rate is less than a hundred hertz.

01:12:00.420 --> 01:12:00.760
<v Brian Amos>Yeah.

01:12:00.920 --> 01:12:02.180
<v Chris Gammell>And, and yeah, exactly.

01:12:02.280 --> 01:12:04.080
<v Chris Gammell>And that, you know, that kind of stuff happens.

01:12:04.740 --> 01:12:05.660
<v Chris Gammell>So yeah.

01:12:06.000 --> 01:12:06.360
<v Chris Gammell>Yeah.

01:12:06.480 --> 01:12:06.900
<v Chris Gammell>Be aware.

01:12:06.900 --> 01:12:09.340
<v Brian Amos>So like in that scenario, how do you find that then?

01:12:09.400 --> 01:12:12.760
<v Brian Amos>So then you'd be like, so just to tie that back to the system viewer and the other stuff

01:12:12.760 --> 01:12:13.240
<v Brian Amos>you talked about.

01:12:13.340 --> 01:12:18.700
<v Brian Amos>So like you'd then see that task kind of just hanging there or what would you see in terms

01:12:18.700 --> 01:12:19.520
<v Brian Amos>of a debug?

01:12:19.820 --> 01:12:19.920
<v Chris Gammell>Yeah.

01:12:19.920 --> 01:12:28.220
<v Chris Gammell>So like if you're, so if you had all ISRs instrumented, if you added instrumentation code,

01:12:28.220 --> 01:12:34.180
<v Chris Gammell>like, you know, enter ISR, exit ISR, then you would actually see the ISR show up right

01:12:34.180 --> 01:12:34.700
<v Chris Gammell>on the screen.

01:12:34.920 --> 01:12:38.620
<v Chris Gammell>And you'd see that you're spending 30 milliseconds inside of this ISR.

01:12:38.620 --> 01:12:45.300
<v Chris Gammell>So barring that you would just see like a blank spot on the screen, for example.

01:12:45.300 --> 01:12:45.600
<v Chris Gammell>Right.

01:12:45.640 --> 01:12:49.660
<v Chris Gammell>And you're like, oh, well there must be some sort of an ISR being, being serviced.

01:12:49.880 --> 01:12:51.180
<v Chris Gammell>Oh, what the heck is that?

01:12:51.920 --> 01:12:55.700
<v Chris Gammell>And then you can kind of go through and start poking around there.

01:12:56.200 --> 01:12:56.320
<v Brian Amos>Yeah.

01:12:56.340 --> 01:12:56.500
<v Brian Amos>Okay.

01:12:56.500 --> 01:12:58.060
<v Brian Amos>So if you have a blank spot, right.

01:12:58.500 --> 01:13:02.600
<v Brian Amos>Can you see like, well, task number one always runs before this blank spot.

01:13:02.680 --> 01:13:04.860
<v Brian Amos>So then you might go and instrument test number one.

01:13:04.920 --> 01:13:05.540
<v Chris Gammell>It might not though.

01:13:05.540 --> 01:13:05.980
<v Chris Gammell>Right.

01:13:06.060 --> 01:13:09.300
<v Chris Gammell>So if you're, if you're asynchronous to that task.

01:13:09.600 --> 01:13:13.480
<v Chris Gammell>Now this is, this is where my, my other, you know, favorite tool comes in.

01:13:13.800 --> 01:13:22.400
<v Chris Gammell>So I typically run with, you know, pretty much always, you know, at minimum, some sort of

01:13:22.400 --> 01:13:23.360
<v Chris Gammell>a debugger, right?

01:13:23.360 --> 01:13:29.500
<v Chris Gammell>If you're doing a lot of this timing kind of stuff, system views or something to visualize

01:13:29.500 --> 01:13:35.040
<v Chris Gammell>tasks is nice for complicated troubleshooting.

01:13:35.880 --> 01:13:42.300
<v Chris Gammell>Certainly, you know, good old print F is kind of nice to have for other, other reasons, but

01:13:42.300 --> 01:13:44.480
<v Chris Gammell>a logic analyzer, right?

01:13:44.480 --> 01:13:51.840
<v Chris Gammell>Just, just instrument the crap out of everything significant coming off of that processor and

01:13:51.840 --> 01:13:52.580
<v Chris Gammell>just leave it there.

01:13:52.580 --> 01:13:52.860
<v Chris Gammell>Right.

01:13:52.860 --> 01:13:59.180
<v Brian Amos>Like the entire time you're doing system integration, man with extra pins on his boards, folks.

01:13:59.500 --> 01:14:01.980
<v Chris Gammell>Well, no, no, no, no, no, no.

01:14:02.180 --> 01:14:02.460
<v Brian Amos>Okay.

01:14:02.620 --> 01:14:02.960
<v Brian Amos>All right.

01:14:03.020 --> 01:14:09.000
<v Chris Gammell>If it's coming off the processor and you're going to an external chip, the it's already

01:14:09.000 --> 01:14:09.660
<v Chris Gammell>there, right?

01:14:10.600 --> 01:14:12.380
<v Chris Gammell>You have a trace somewhere.

01:14:12.600 --> 01:14:13.860
<v Chris Gammell>I mean, assuming, okay.

01:14:14.020 --> 01:14:16.120
<v Chris Gammell>I, so a lot of the stuff I work on is bigger.

01:14:16.740 --> 01:14:21.700
<v Chris Gammell>You know, I can afford to actually put down like a very, very tiny test point.

01:14:21.700 --> 01:14:25.060
<v Brian Amos>So you're not saying like, you're not, you don't have like 16 extra GPIOs that are going

01:14:25.060 --> 01:14:25.600
<v Brian Amos>out to a digit.

01:14:25.780 --> 01:14:26.540
<v Brian Amos>No, they're not extra.

01:14:26.660 --> 01:14:27.320
<v Chris Gammell>You're saying like.

01:14:27.620 --> 01:14:28.700
<v Chris Gammell>Instrument your external buses.

01:14:29.100 --> 01:14:29.720
<v Chris Gammell>That's what I'm saying.

01:14:30.940 --> 01:14:31.220
<v Brian Amos>Okay.

01:14:31.660 --> 01:14:31.860
<v Chris Gammell>Right.

01:14:31.920 --> 01:14:39.100
<v Chris Gammell>So, you know, so if you're, if you're accessing some external chip and it's a zero bus instrument

01:14:39.100 --> 01:14:45.360
<v Chris Gammell>and then you get a, it's amazing how much you can learn by just like taking a glance

01:14:45.360 --> 01:14:49.060
<v Chris Gammell>over at your, your logic analyzer screen.

01:14:49.840 --> 01:14:55.320
<v Chris Gammell>And, you know, you, you, you get, you, it's like a, it's like the pulse of the system, right?

01:14:55.620 --> 01:14:59.560
<v Chris Gammell>Like, you know, you just glance over there and, you know, you see these little heartbeats

01:14:59.560 --> 01:15:03.840
<v Chris Gammell>because you know that, you know, this, this ADC is always accessed every 10 milliseconds.

01:15:03.840 --> 01:15:09.700
<v Chris Gammell>And then, you know, you, you can start, if you have a couple of extra GPIO lines in that

01:15:09.700 --> 01:15:14.800
<v Chris Gammell>case, you bring those out and then you start, you know, you just go to old GPIO toggle, right?

01:15:15.080 --> 01:15:19.100
<v Chris Gammell>But if you do it with a logic analyzer, then all of a sudden you have really high resolution.

01:15:19.760 --> 01:15:25.360
<v Chris Gammell>And if you have a problematic ISR, then you just toggle a GPIO register at the beginning

01:15:25.360 --> 01:15:31.000
<v Chris Gammell>and then, you know, neither, you know, do whatever you need to toggles or highs and lows,

01:15:31.000 --> 01:15:33.600
<v Chris Gammell>whatever, you get a really clear idea of what's going on.

01:15:33.760 --> 01:15:37.700
<v Brian Amos>So when you say like instrumenting the external stuff, you mean like just putting test points

01:15:37.700 --> 01:15:40.100
<v Brian Amos>down or literally soldering test points, physical.

01:15:40.320 --> 01:15:40.580
<v Brian Amos>Yes.

01:15:41.120 --> 01:15:41.440
<v Brian Amos>Yeah.

01:15:41.640 --> 01:15:41.820
<v Brian Amos>Yeah.

01:15:41.820 --> 01:15:45.640
<v Chris Gammell>I'm, I'm a, you know, I'm, I'm, I'm a really low level guy.

01:15:45.980 --> 01:15:50.260
<v Chris Gammell>So I'm not, you know, I, I, I have a, you know, kind of thing.

01:15:50.320 --> 01:15:51.580
<v Chris Gammell>I have a soldering art at my desk.

01:15:51.620 --> 01:15:53.280
<v Chris Gammell>I'm not just a, just a software guy.

01:15:53.980 --> 01:15:54.420
<v Brian Amos>Solid.

01:15:54.920 --> 01:15:55.280
<v Brian Amos>Solid.

01:15:55.660 --> 01:15:57.060
<v Brian Amos>Passes, passes the amp power test.

01:15:57.160 --> 01:15:57.500
<v Brian Amos>That's good.

01:15:58.760 --> 01:16:00.440
<v Chris Gammell>I once talked to somebody and.

01:16:00.440 --> 01:16:01.820
<v Brian Amos>You have chosen wisely.

01:16:02.320 --> 01:16:02.680
<v Chris Gammell>Yeah.

01:16:02.740 --> 01:16:08.260
<v Chris Gammell>We're getting started on this project and, and he was, um, it's like an old school double

01:16:08.260 --> 01:16:13.620
<v Chris Gammell>E and we're talking and he's like, yeah, so what questions do you have?

01:16:13.960 --> 01:16:17.980
<v Chris Gammell>And I think the first thing I asked was, well, do you have a schematic?

01:16:18.800 --> 01:16:19.700
<v Chris Gammell>I was like, yeah.

01:16:21.140 --> 01:16:24.820
<v Chris Gammell>Like, whoa, I thought you were a software guy.

01:16:24.820 --> 01:16:30.640
<v Chris Gammell>No, it's, I mean, yeah, I'm, I'm brought into right software, but I need to know what the

01:16:30.640 --> 01:16:31.340
<v Chris Gammell>hardware is doing.

01:16:31.600 --> 01:16:31.960
<v Chris Gammell>Obviously.

01:16:32.640 --> 01:16:32.940
<v Brian Amos>Yeah.

01:16:33.120 --> 01:16:34.100
<v Chris Gammell>Apparently not everybody.

01:16:34.100 --> 01:16:34.680
<v Chris Gammell>This is not a buy box.

01:16:35.020 --> 01:16:35.500
<v Brian Amos>But yeah.

01:16:36.120 --> 01:16:36.480
<v Brian Amos>Hmm.

01:16:36.480 --> 01:16:38.360
<v Brian Amos>So then, okay.

01:16:38.360 --> 01:16:41.140
<v Brian Amos>So now you mentioned Amazon bought free art toss.

01:16:41.260 --> 01:16:45.740
<v Brian Amos>They're putting more functionality in there, but then even like you also mentioned, you know,

01:16:45.740 --> 01:16:46.860
<v Brian Amos>screens are coming in.

01:16:46.860 --> 01:16:52.460
<v Brian Amos>So now you need to move up the stack and do more complex stuff at third party libraries.

01:16:52.460 --> 01:16:57.980
<v Brian Amos>What does that then do for you as like this low level person that does understand all that stuff,

01:16:58.040 --> 01:17:02.660
<v Brian Amos>but then most of the processing time is kind of at that, the higher level functions, like a screen

01:17:02.660 --> 01:17:06.700
<v Brian Amos>maybe, or a, you know, wifi, wifi connection or something like that.

01:17:07.240 --> 01:17:11.720
<v Chris Gammell>And again, that's, that's my, my bias towards prioritization, right?

01:17:11.800 --> 01:17:16.600
<v Chris Gammell>Like, I'm not going to say that stuff is extra, but it's less essential.

01:17:17.080 --> 01:17:17.480
<v Chris Gammell>Right.

01:17:17.660 --> 01:17:22.040
<v Chris Gammell>And in, in some cases, you know, maybe, maybe it's super essential to that particular product,

01:17:22.040 --> 01:17:25.320
<v Brian Amos>but yeah, I think it's just the stuff that you've been doing for sure.

01:17:25.360 --> 01:17:29.240
<v Brian Amos>It sounds like, you know, like high reliability type stuff, real things that actually need

01:17:29.240 --> 01:17:30.120
<v Brian Amos>the real time piece of it.

01:17:30.300 --> 01:17:30.480
<v Chris Gammell>Yeah.

01:17:30.720 --> 01:17:30.900
<v Chris Gammell>Yeah.

01:17:31.280 --> 01:17:34.820
<v Chris Gammell>So yeah, you just, you know, you, I mean, you just kind of, you just kind of accept it.

01:17:34.820 --> 01:17:35.040
<v Chris Gammell>Right.

01:17:35.360 --> 01:17:39.660
<v Chris Gammell>And then, you know, at some point there are always going to be trade-offs to be made.

01:17:39.800 --> 01:17:46.480
<v Chris Gammell>You know, uh, if you, if you have that kind of glitchy feeling UI, then maybe you need

01:17:46.480 --> 01:17:49.000
<v Chris Gammell>to like tone down the animations or something.

01:17:49.180 --> 01:17:49.660
<v Chris Gammell>I don't know.

01:17:50.160 --> 01:17:51.300
<v Chris Gammell>There's, you know, or.

01:17:52.040 --> 01:17:55.800
<v Chris Gammell>You know, there's, there's a trade-off to be made, right?

01:17:55.860 --> 01:17:58.920
<v Chris Gammell>You either, either throw hardware at it or, or simplify it.

01:17:59.440 --> 01:18:01.120
<v Chris Gammell>One of the two, but.

01:18:01.280 --> 01:18:01.400
<v Chris Gammell>Yeah.

01:18:02.260 --> 01:18:02.620
<v Brian Amos>Okay.

01:18:03.000 --> 01:18:06.780
<v Brian Amos>Are you feeling the pull of the embedded Linux space as well?

01:18:06.860 --> 01:18:11.520
<v Brian Amos>Like, do you, do you feel that like either, I guess from, from, you know, your, your day-to-day

01:18:11.520 --> 01:18:12.860
<v Chris Gammell>work or your work in your past?

01:18:12.860 --> 01:18:15.280
<v Chris Gammell>I mean, I've done, I've done a few embedded Linux projects.

01:18:15.280 --> 01:18:18.420
<v Chris Gammell>So it's, it's not something totally foreign.

01:18:18.420 --> 01:18:25.780
<v Chris Gammell>I mean, I, I like, you know, suffered through Yocto for six, six months, getting a system on

01:18:25.780 --> 01:18:30.240
<v Chris Gammell>modules set up and brought up and, uh, in a, in a fully networked environment.

01:18:30.240 --> 01:18:34.720
<v Chris Gammell>So, yeah, I mean, you know, depending on the, on the product, it makes a lot of sense.

01:18:34.720 --> 01:18:39.240
<v Chris Gammell>I'm not, I'm not at all opposed to full operating systems, but they're great.

01:18:39.380 --> 01:18:42.820
<v Chris Gammell>You have, you have a whole bunch of other people's code that you can use most of the

01:18:42.820 --> 01:18:48.180
<v Chris Gammell>time and get a whole bunch of functionality that you don't need to directly create, which

01:18:48.180 --> 01:18:48.740
<v Chris Gammell>is awesome.

01:18:49.480 --> 01:18:49.620
<v Brian Amos>Yeah.

01:18:50.000 --> 01:18:50.200
<v Chris Gammell>Yeah.

01:18:50.200 --> 01:18:57.020
<v Chris Gammell>And in a lot of cases, you know, what works really well is if you have very strict real

01:18:57.020 --> 01:19:02.340
<v Chris Gammell>time requirements and you have a little bit of wiggle room in your bomb, you know, just

01:19:02.340 --> 01:19:06.700
<v Chris Gammell>add in a microcontroller to do, you know, the simple hard real time stuff.

01:19:06.700 --> 01:19:11.880
<v Chris Gammell>And then, you know, everything else that requires these, you know, crazy stacks and protocols that

01:19:11.880 --> 01:19:17.180
<v Chris Gammell>you'd rather not look at or recreate or you can't or whatever, you know, run that on, on

01:19:17.180 --> 01:19:22.240
<v Chris Gammell>an OS and then, you know, just have some sort of a serial interface between them.

01:19:22.920 --> 01:19:24.560
<v Chris Gammell>So, yeah, yeah.

01:19:24.900 --> 01:19:27.440
<v Chris Gammell>Thankfully, hardware is less expensive every day.

01:19:27.640 --> 01:19:32.440
<v Chris Gammell>So, you know, some, sometimes we can solve problems with, with just more hardware every

01:19:32.440 --> 01:19:32.920
<v Chris Gammell>once in a while.

01:19:33.140 --> 01:19:33.300
<v Chris Gammell>Right.

01:19:33.300 --> 01:19:33.740
<v Chris Gammell>Yeah.

01:19:33.960 --> 01:19:35.080
<v Chris Gammell>As long as we can buy it.

01:19:36.620 --> 01:19:37.060
<v Chris Gammell>Yeah.

01:19:37.260 --> 01:19:37.540
<v Chris Gammell>Yeah.

01:19:37.580 --> 01:19:38.320
<v Chris Gammell>There is that.

01:19:38.780 --> 01:19:45.080
<v Chris Gammell>And then that's another good reason to write code that doesn't directly access your processor

01:19:45.080 --> 01:19:46.300
<v Chris Gammell>registers.

01:19:46.300 --> 01:19:46.660
<v Chris Gammell>Right.

01:19:46.660 --> 01:19:46.980
<v Chris Gammell>Registers.

01:19:47.100 --> 01:19:47.260
<v Chris Gammell>Right.

01:19:47.360 --> 01:19:52.580
<v Chris Gammell>Because it might, it's probably these days, it's probably going to be running on a couple

01:19:52.580 --> 01:19:53.500
<v Chris Gammell>of different processors.

01:19:54.940 --> 01:19:55.300
<v Brian Amos>Yeah.

01:19:55.520 --> 01:19:56.140
<v Brian Amos>Yeah, exactly.

01:19:56.840 --> 01:19:57.880
<v Brian Amos>So then, okay.

01:19:57.920 --> 01:19:59.100
<v Brian Amos>This is the last thing I promise.

01:19:59.180 --> 01:20:03.560
<v Brian Amos>Cause I've kept you long enough here, but so then if you do have that, that co-processor

01:20:03.560 --> 01:20:04.220
<v Brian Amos>there, right.

01:20:04.220 --> 01:20:08.360
<v Brian Amos>And it's just doing a couple of small functions that would normally have free R toss as well.

01:20:08.400 --> 01:20:12.280
<v Brian Amos>Or would that be, I guess, how often do you find yourself going back to super loop then?

01:20:13.220 --> 01:20:14.020
<v Brian Amos>You personally.

01:20:14.180 --> 01:20:14.900
<v Chris Gammell>Me personally.

01:20:15.400 --> 01:20:15.640
<v Brian Amos>Yeah.

01:20:15.640 --> 01:20:22.860
<v Chris Gammell>Whenever, if I know that something is simple enough that I'm not going to want to do anything

01:20:22.860 --> 01:20:25.980
<v Chris Gammell>concurrently, then, you know, sure.

01:20:26.320 --> 01:20:27.400
<v Chris Gammell>Super, super loop.

01:20:27.480 --> 01:20:28.440
<v Chris Gammell>It is no problem at all.

01:20:28.560 --> 01:20:29.200
<v Chris Gammell>It's great.

01:20:29.200 --> 01:20:36.420
<v Chris Gammell>The minute that like for, for new projects, I wind up, I guess the, the things that I create

01:20:36.420 --> 01:20:44.280
<v Chris Gammell>are often, the projects that I'm involved with wind up being large enough that at some

01:20:44.280 --> 01:20:48.260
<v Chris Gammell>point it's highly desirable to have some level of concurrency.

01:20:48.260 --> 01:20:49.260
<v Brian Amos>Yeah.

01:20:49.260 --> 01:20:49.260
<v Speaker ?>

01:20:49.260 --> 01:20:55.480
<v Chris Gammell>So, you know, in that case, you know, it doesn't really make a lot of sense to, to try to shoe

01:20:55.480 --> 01:20:56.700
<v Chris Gammell>transform that into a super loop.

01:20:56.700 --> 01:21:03.700
<v Chris Gammell>If you've already got like a whole bunch of stuff that's operating well and kind of tailored

01:21:03.700 --> 01:21:04.700
<v Chris Gammell>towards an R toss.

01:21:04.700 --> 01:21:10.700
<v Chris Gammell>There, there's one case in the past where we had written a lot of libraries, like some, some

01:21:10.700 --> 01:21:11.700
<v Chris Gammell>middleware kind of stuff.

01:21:11.700 --> 01:21:18.660
<v Chris Gammell>And we actually couldn't afford the overhead of the scheduler that happened one time, you know,

01:21:18.660 --> 01:21:25.220
<v Chris Gammell>this processor was like just totally maxed out super, super tight timing constraints.

01:21:25.220 --> 01:21:30.420
<v Chris Gammell>And, you know, there was just no way to, to, to run an R toss on it.

01:21:31.360 --> 01:21:38.860
<v Chris Gammell>But in that case, all we really did was the middleware was created in such a way that, you

01:21:38.860 --> 01:21:44.460
<v Chris Gammell>know, instead of a free R toss queue, we were just using like an in-house ring buffer, for

01:21:44.460 --> 01:21:44.900
<v Chris Gammell>example.

01:21:45.540 --> 01:21:45.800
<v Chris Gammell>Right.

01:21:45.800 --> 01:21:51.500
<v Chris Gammell>So you can, you can, you can kind of, you can abstract things well enough that a lot of

01:21:51.500 --> 01:21:54.480
<v Chris Gammell>the code doesn't actually care what it's running on.

01:21:54.480 --> 01:21:55.920
<v Chris Gammell>At the end of the day.

01:21:55.960 --> 01:21:56.180
<v Chris Gammell>Right.

01:21:56.180 --> 01:21:59.860
<v Chris Gammell>It's just like, Hey, I have data for somebody else here.

01:21:59.860 --> 01:22:02.560
<v Chris Gammell>I'm going to, you know, get your data here.

01:22:02.840 --> 01:22:03.240
<v Chris Gammell>Yeah.

01:22:03.400 --> 01:22:04.540
<v Chris Gammell>And that's, and that's all it is.

01:22:04.540 --> 01:22:06.960
<v Chris Gammell>And it hands it off and you know, nobody cares.

01:22:07.360 --> 01:22:07.580
<v Chris Gammell>Yeah.

01:22:07.800 --> 01:22:08.060
<v Chris Gammell>Yeah.

01:22:08.060 --> 01:22:13.160
<v Chris Gammell>So in that case, you know, you have something that's super, super fast, you know, in that,

01:22:13.340 --> 01:22:16.000
<v Chris Gammell>in that middleware can run on, on whatever it does.

01:22:16.100 --> 01:22:18.100
<v Chris Gammell>It didn't, it could run on bare metal.

01:22:18.300 --> 01:22:19.780
<v Chris Gammell>It could run on an R toss.

01:22:19.820 --> 01:22:21.660
<v Chris Gammell>It could run on a full operating system.

01:22:21.660 --> 01:22:28.080
<v Chris Gammell>As long as you're, as long as you're not like, you know, tying everything super, you

01:22:28.080 --> 01:22:31.880
<v Chris Gammell>know, like really, really tight coupling between all your modules and everything.

01:22:32.120 --> 01:22:34.000
<v Chris Gammell>And you have consistent interfaces.

01:22:34.000 --> 01:22:36.700
<v Chris Gammell>You can just very fluidly move between things.

01:22:37.040 --> 01:22:37.760
<v Chris Gammell>That's, that's ideal.

01:22:37.860 --> 01:22:40.540
<v Chris Gammell>But I could work on stuff that has super loops.

01:22:40.540 --> 01:22:48.060
<v Chris Gammell>It oftentimes by the end of, well, so, you know, I, I think I, I'm in like the industrial

01:22:48.060 --> 01:22:49.360
<v Chris Gammell>space most of the time.

01:22:50.140 --> 01:22:50.660
<v Chris Gammell>Yep.

01:22:50.660 --> 01:22:58.760
<v Chris Gammell>So a lot of, a lot of our stuff has like some level of network connectivity, some level of,

01:22:58.760 --> 01:23:04.340
<v Chris Gammell>you know, like manufacturing test code and, you know, like all that kind of stuff.

01:23:04.340 --> 01:23:11.920
<v Chris Gammell>So there's usually it's, it's desirable to like add in other features that kind of need

01:23:11.920 --> 01:23:14.680
<v Chris Gammell>to operate with some level of concurrency at some point.

01:23:14.680 --> 01:23:19.820
<v Chris Gammell>So it just more often than not, it makes a lot of sense and it's not, you know, from

01:23:19.820 --> 01:23:24.620
<v Chris Gammell>like a ROM and RAM perspective, free R toss, especially it's pretty cheap.

01:23:25.240 --> 01:23:25.560
<v Chris Gammell>Yeah.

01:23:25.560 --> 01:23:27.560
<v Chris Gammell>There, there isn't a ton of overhead there.

01:23:27.900 --> 01:23:28.220
<v Chris Gammell>Yeah.

01:23:28.220 --> 01:23:32.800
<v Chris Gammell>So it's not like, you know, if you're, you know, you're, you're using like a Python interpreter

01:23:32.800 --> 01:23:41.480
<v Chris Gammell>or something like that where, oh yeah, look, I, I have this, you know, 256 K ROM and it's

01:23:41.480 --> 01:23:46.020
<v Chris Gammell>almost big enough for my, my 20 line script or whatever.

01:23:46.160 --> 01:23:50.380
<v Chris Gammell>I don't, I don't know how big the normal, normal runtime environment for that is, but

01:23:50.380 --> 01:23:51.720
<v Brian Amos>you know.

01:23:52.420 --> 01:23:55.600
<v Brian Amos>It is impressive how they squeeze it down these days, but yeah, it's a, yeah, it's still,

01:23:55.980 --> 01:23:56.540
<v Brian Amos>it's sizable.

01:23:56.740 --> 01:23:56.840
<v Brian Amos>Yeah.

01:23:57.620 --> 01:24:02.580
<v Brian Amos>Brian, where can people find out more about you, about your book and buy your book and

01:24:02.580 --> 01:24:03.320
<v Brian Amos>hopefully try it out.

01:24:03.360 --> 01:24:05.580
<v Brian Amos>And also where can they find the, the boards to run?

01:24:06.500 --> 01:24:06.860
<v Brian Amos>Sorry.

01:24:07.540 --> 01:24:08.540
<v Brian Amos>That last one was a.

01:24:08.880 --> 01:24:09.960
<v Brian Amos>Bubble gum tap shoes.

01:24:10.260 --> 01:24:10.620
<v Chris Gammell>Bubble gum.

01:24:10.620 --> 01:24:11.060
<v Brian Amos>Yeah.

01:24:11.060 --> 01:24:11.300
<v Brian Amos>Yeah.

01:24:11.300 --> 01:24:11.500
<v Brian Amos>Yeah.

01:24:11.500 --> 01:24:11.620
<v Brian Amos>Yeah.

01:24:12.900 --> 01:24:16.880
<v Chris Gammell>Well, Mouser does have, well, as of yesterday, they had 32 of them.

01:24:17.320 --> 01:24:17.660
<v Chris Gammell>All right.

01:24:17.780 --> 01:24:18.760
<v Brian Amos>See, he did his homework.

01:24:18.960 --> 01:24:20.200
<v Brian Amos>He checked before he came on the show.

01:24:20.260 --> 01:24:20.740
<v Brian Amos>That was really nice.

01:24:20.900 --> 01:24:21.100
<v Chris Gammell>I did.

01:24:21.220 --> 01:24:22.400
<v Chris Gammell>I, well, I don't know.

01:24:22.420 --> 01:24:23.300
<v Chris Gammell>Who knows by today?

01:24:24.020 --> 01:24:28.740
<v Chris Gammell>Uh, but yeah, I'm, I'm probably easiest to get a hold of through LinkedIn.

01:24:28.740 --> 01:24:34.520
<v Chris Gammell>If you search for Brian Amos embedded, you'll be able to find me, uh, the books on Amazon.

01:24:35.200 --> 01:24:36.640
<v Chris Gammell>So that's nice and easy.

01:24:36.640 --> 01:24:42.160
<v Chris Gammell>You can email me directly, uh, Brian Amos at holistic embedded.com.

01:24:42.820 --> 01:24:47.500
<v Chris Gammell>And I've, I've got a landing page as well, but that's not really worth mentioning.

01:24:49.180 --> 01:24:50.220
<v Chris Gammell>Find me on LinkedIn.

01:24:51.240 --> 01:24:51.640
<v Chris Gammell>Yeah.

01:24:51.800 --> 01:24:52.000
<v Chris Gammell>Yeah.

01:24:52.140 --> 01:24:52.260
<v Brian Amos>Yeah.

01:24:52.260 --> 01:24:54.160
<v Brian Amos>That's great.

01:24:54.660 --> 01:24:54.960
<v Brian Amos>All right.

01:24:54.960 --> 01:24:58.240
<v Brian Amos>Well, thanks for, uh, first off, thanks for writing this book is really useful for me.

01:24:58.660 --> 01:25:00.080
<v Brian Amos>And thanks for coming to talk about it today.

01:25:00.360 --> 01:25:01.100
<v Brian Amos>Thanks for having me.

01:25:01.100 --> 01:25:03.140
<v Brian Amos>This, this helped me understand it even more.

01:25:03.360 --> 01:25:04.480
<v Brian Amos>So we'll have to chat soon.

01:25:04.720 --> 01:25:05.720
<v Brian Amos>Thank you very much, Chris.

01:25:05.720 --> 01:25:28.200
<v Brian Amos>Mutex

01:25:28.200 --> 01:25:32.440
<v Brian Amos>Semaphore
