Leave. Seriously, walk away. Here are some thoughts:

1. The situation is poisoned. If you stay and force a battle of wills, it will be hugely distracting in a way that adds no value to the company (and remember, building a great company is why you did this in first place), not to mention personally painful for you. That the CEO and CTO have lost confidence in you means it's just going to suck from here on out. Even if you win, that just means disempowering the CTO (or replacement CTO if the current one leaves in frustration, which doesn't seem improbable). Maybe the CTO is wrong, but if he's saddled with someone he doesn't want and can't get rid of because of special cofounder status, it's going to create a pretty shitty working environment for everyone. And if he wins (say, because the CEO votes you out), then that's the same as you sliding out anyway.

2. The CTO definitely hasn't overstepped his boundaries; he's doing his job. He's responsible for running the engineering team and delivering a product. If he thinks you're holding the company back, he'd be being irresponsible not to do something about it. Of course, he could be wrong and there's no way for me (or anyone else here) to determine that. So you have to ask yourself what you really think is best for the company. If it's you leaving, tanking the company in a huge fight (or just dragging it down by sticking around) will just destroy whatever equity you have in it. If it's you staying and you're confident (after putting aside your ego, considering it from other peoples' views, etc), then yeah, convince the CEO and then together fire the CTO for being so terribly wrong. But it's not an issue of boundaries. So: would you hire you?

3. Closely related: what are you doing cofounding companies with that little confidence in yourself? If someone came to you and said, "hey, I haven't coded much and don't have a lot of experience", would you think that was a wise investment? Because you went all in on that investment. Do some work with some guidance and lower stakes and learn your craft. I don't at all mean that as "noob go home" (I have no idea how good you actually are); I mean that your description basically acknowledges you don't think you're the right person for the job of technical cofounder.

4. Your CEO sounds clueless and you should take this opportunity to bail out. If the CTO is wrong about you, the CEO's confidence in him is misplaced and he's also allowing unnecessary complications to destroy his engineering team. If the CTO is right that you don't even belong on the team, then why did the CEO partner with you in the first place? Maybe he thought of you as a temporary pawn to sacrificed at the right time. Maybe he just doesn't know what he's doing. None of those are good. Get out.

5. You say in one of the comments that you don't want to lose your unvested shares and that you've taken on a lot of opportunity cost. The whole point of the vesting is that you get what you've worked for. If you don't think the vested equity you have is commensurate with the work you've done, working more isn't going to fix that. You'll just continue getting screwed, putting in more time and earning the same vesting that you're unhappy with. I know you probably feel pot-committed, but the best thing to do when you have a bad hand is fold your cards and move on.

6. Startups are hard. They're painful work, especially when things go bad, to the point that I wonder why we do it in the best of situations. If you throw in the stress of trying to prove you even belong, it's just shitty. Save your happiness and leave.

7. It's important not to think of these decisions as an affront to your pride. The never-say-die bromide of startup cofounders the world over is mostly bullshit. Make sure you're in a healthy situation with a real chance of success. Quitting isn't shameful, but sabotaging your happiness and the value of your investment because it hurts your ego is very unwise. I don't know whether or not I'd be wise in that situation either--I certainly have plenty of ego--but of course that's why you asked us: we're not involved.

My guess is that once you leave, clear your head, and figure out what you want to do next, you'll look back and say, "wow, I'm glad I got out of that."